2
我在理解pandas.Panel(3D数据结构)的索引时遇到了一些麻烦。在documentation中指出,分度工作方式:索引pandas.Panel违反直觉或错误?
获取值从物体与多轴选择使用如下标记(使用的.loc作为一个例子,但适用于.iloc和.IX以及)。任何轴访问器都可能是空片:。被忽略的轴被假定为:。 (egploc [ 'A']是当量至p.loc [ '一个',:,:])
p.loc [item_indexer,major_indexer,minor_indexer]
现在我将认为其余指数的订单时,被提取的数据帧不改变,而是:
from pandas import Panel
from numpy import arange
p = Panel(arange(24).reshape(2,3,4))
p.shape
Out[4]: (2, 3, 4)
p.iloc[0].shape # original order
Out[5]: (3, 4)
p.iloc[:,0].shape # transposed
Out[6]: (4, 2)
p.iloc[:,:,0].shape # transposed
Out[7]: (3, 2)
p.iloc[:,0,:].shape # transpose (same as [6])
Out[8]: (4, 2)
p.iloc[1:,0,:].shape # Slicing item_indexer, then transpose
Out[9]: (4, 1)
p.iloc[1:,0].shape # Expected to get the same as [9], but slicing minor_indexer instead????
Out[10]: (3, 2)
为什么索引major_index或minor_index,但不是item_index当数据帧调换任何想法?为什么最后一个例子与之前的例子不同?
我想没有人知道... – Rob 2015-07-24 09:56:36