找不到短轴上的项目

时间:2018-10-22 12:41:44

标签: python panel

我正在尝试通过以下面板进行一些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]'

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

您需要按列表中的元组进行选择:

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

因为:

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