考虑以下代码:
sfix = sub['fix'] # a pandas.Panel
(sfix.minor_xs('tstop') - sfix.minor_xs('tstart')) # slicey slicey!
输出:
^{pr2}$此输出对应于Panel对象中包含的8个数据帧的tstop
和{
这些列都包含相同类型的数据,我想将它们堆叠成一个系列,因此:
s = pd.concat([df[i] for i in df])
这是一个好的开始,但现在我的所有索引都被复制了8次:
>>> s.ix[0]
0 98
0 184
0 178
0 188
0 176
0 234
0 128
0 82
dtype: float64
从这里开始,我不太清楚如何重新索引我的系列,使索引从0变为len(s)
。我试过以下几种方法,但没有效果:
s.reindex(copy=True)
s.reindex(index=xrange(len(s)), copy=True)
我错过了什么?在
IIUC,您可以使用
reset_index(drop=True)
:这也应该行得通
相关问题 更多 >
编程相关推荐