无法在短轴中找到项目

Can't locate items in minor axis

我正在尝试对以下面板进行一些 pd.Panel 操作:

print(panell)
print(panell.shape)

给出:

<class 'pandas.core.panel.Panel'>
Dimensions: 9 (items) x 60 (major_axis) x 114 (minor_axis)
Items axis: 31.5hz to 8000hz
Major_axis axis: 2018-10-22 07:00:00 to 2018-10-24 18:00:00
Minor_axis axis: (1, 1) to (38, 3)

(9, 60, 114)

然后我想遍历 minor_axis 但它无法找到正确的标签。例如,两者:

print(panell.loc[:,:,'(38, 3)'])
print(panell[:,:,'(38, 3)'])

给出:

KeyError: 'the label [(38, 3)] is not in the [minor_axis]'

有什么建议吗?

您需要 select 列表中的元组:

print(panell.loc[:,:,[(38, 3)]])

因为:

print (type(panell.minor_axis[0]))
<class 'tuple'>