I can index a Panel to get a data frame, e.g. by major_axis:
>>> p = pd.Panel(np.arange(8).reshape(2,2,2),items=('A1','B1'),major_axis=('A2','B2'),minor_axis=('A3','B3'))
>>> p.loc[:,'A2',:]
A1 B1
A3 0 4
B3 1 5
But if I do the same index when the minor_axis is a MultiIndex the resulting data frame is unexpectedly transposed:
mi = pd.MultiIndex((['A3','B3'],['a','b']), [(0,0),(1,1)])
p = pd.Panel(np.arange(8).reshape(2,2,2),items=('A1','B1'),major_axis=('A2','B2'),minor_axis=mi)
p.loc[:,'A2',:]
A3
b b
A1 0 1
B1 4 5
Actually I think the second behaviour is closer to what I expect - the items axis becomes dimension 0 of the DataFrame. But whichever is used, we should have stability, especially if 1-item MultiIndex objects automatically become Index objects.
Comment From: jreback
so these hit 2 slightly different paths, and the one 2nd one has a 'fix' for this issue: https://github.com/pydata/pandas/issues/7516 and in the code here
I remember making this change and it seems reasonable.
If you'd like to read the other issue and see what is most logical would be helpful.
Comment From: benmoran
@jreback sorry, I'm not sure what I'm looking at in the other issue you referenced?
This is the behaviour that seems "most logical" to me: - most important is that whatever type my indices happen to be doesn't affect the transposition order of the output - secondly, I'd expect that removing a dimension doesn't change the order of the other dimensions
I think the latter is what Numpy does, so "np.random.randn(3,4,5)[:,1,:].shape" gives (3,5) and not (5,3).
Comment From: jreback
closing as Panels are deprecated