0

enter image description here

I have trouble sending my data frame to panelOLS model. the dataframe didn't using any column as index

then it returns an error massage: ValueError: Series can only be used with a 2-level MultiIndex

Doeas that mean I need to use double index and use datetime type as my indices?

J.Guo
  • 37
  • 5
  • Try use suggestion from dupe answer, if still problem let me know. – jezrael Jul 08 '22 at 05:20
  • Yes, I am aware of a dupe answer. But I think it may not fit my situation. It suggest to use set_index() to make a secondary index after converting 'year' to datetime. My major concern is to make the 'YEAR_QUARTER' into a 2 level multindex – J.Guo Jul 08 '22 at 05:34
  • 1
    yop, try `df.index = pd.to_datetime(df.index.str.replace('_','Q', regex=True))` and then add some column to index with `append=True` - check answer. – jezrael Jul 08 '22 at 05:35

0 Answers0