So I've been working on this problem for some time and have not figured a solution. I want to be able to store a dataframe created on or worked on from python directly into Stata.
Here is my attempt at this solution
now lets say I want to store year. This is what I wrote
which produces a new column named year and gives me no errors, but unfortunately does not store the desired values in the variable. On top of that, there does not seem to be a way to do it with the whole database (unless they're all of the same time and loop over them and do this procedure which does not work)
Here is my attempt at this solution
Code:
frame create ds python import pandas as pd import sfi as sfi from sfi import Frame, Data from pandas import Series, DataFrame data = {'school': ['UCSC', 'UCLA', 'UCD', 'UCSB', 'UCI', 'UCSF'],'year': [2000, 2001, 2002, 2001, 2002, 2003], 'num': [4000, 3987, 5000, 4321, 5000, 8200]} ds = pd.DataFrame(data) type(ds)
Code:
Data.addVarDouble('year') Data.store('year',None,ds['year']) end tab year
which produces a new column named year and gives me no errors, but unfortunately does not store the desired values in the variable. On top of that, there does not seem to be a way to do it with the whole database (unless they're all of the same time and loop over them and do this procedure which does not work)
Comment