我有以下数据框df
:
Y X
2011-01-26 14:00:30 1 -0.0174 -0.2139
2 0.1234 0.1357
3 0.3652 0.7352
4 0.1111 0.3481
2011-01-26 14:01:30 1 -0.0124 -0.7139
2 0.1444 0.1217
3 0.3112 0.8882
4 0.1222 0.9911
.... (one minute increments)
.... (following day)
2011-01-27 14:00:30 1 -0.0884 -0.2144
2 0.1834 0.2227
3 0.3699 0.7555
4 0.2311 0.3481
2011-01-27 14:01:30 1 -0.0333 -0.7139
2 0.1444 0.1217
3 0.3443 0.1182
4 0.1442 0.9111
....
df.index
Out[38]:
MultiIndex(levels=[[2011-01-26 14:00:30, 2011-01-26 14:01:30, 2011-01-26 14:02:30, 2011-01-26 14:03:30, ....], [u'1', u'2', u'3',....]
如果我运行以下小组/ Fama-Macbeth回归:
reg = pd.fama_macbeth(y=df.Y, x=df.X)
我收到此错误消息:
raise ValueError("Can't convert non-uniquely indexed "
ValueError: Can't convert non-uniquely indexed DataFrame to Panel
为什么?
我猜它与我的多索引的标签有关我相信...我的多索引是使用以下方法创建的:
arrays = [np.array(pd.to_datetime(df['Col1'])), np.array(df['Col2'])]
df.index = arrays
我该怎么做才能解决这个问题?