1

I have the following dataframe:

url='https://raw.githubusercontent.com/108michael/ms_thesis/master/crsp.dime.mpl.df.1'

df=pd.read_csv(url, index_col=0)

df=df.pivot_table(index='date',columns='cid', fill_value=0,aggfunc=np.mean)

df=df.T.to_panel()

df=df.transpose(2,0,1)

df

<class 'pandas.core.panel.Panel'>
Dimensions: 505 (items) x 10 (major_axis) x 19 (minor_axis)
Items axis: N00000010 to N00035686
Major_axis axis: 2005 to 2014
Minor_axis axis: candcfscore.dyn_static to dir_ind_expendituresfor

I need to run a panel regression on it. To do that I am using the following code:

reg  = PanelOLS(y=df['billsum_support'],x=df[['years_exp', 'unemployment', 'dir_ind_expendituresfor']],time_effects=True)
reg

Which is giving me the following error: KeyError: 'billsum_support'

My understanding is that Items axisrepresents different data frames. Within each data frame I have different endogenousand exogenousvariables that I intend to implement for different regression outcomes.

I have looked and am continuing to look at some of the posts regarding Panel Fixed Effects in Pandas. It seems to be deprecated; does anyone has a clue on how to implement a simple Panel OLS in Pandas/Python?

Collective Action
  • 7,607
  • 15
  • 45
  • 60
  • 1
    It looks like `billsum_support` is not in your items axis. I guess `df.transpose` should get the arguments in a different order. – ptrj May 08 '16 at 20:23
  • @ptrj: Thank you for your comment! I am going to approach that problem again later; when I do, I will bear in mind your suggestion. Right now I am working on refining my pooled regression. – Collective Action May 08 '16 at 20:50
  • This problem has been [solved](http://stackoverflow.com/questions/37107796/pandas-trouble-implementing-panel-ols/37108308#37108308). – Collective Action May 09 '16 at 05:46

0 Answers0