You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given the above, I would expect leaving out the ['b1', 'b2'] to work as well, but in this case it looks like the axis=1 is ignored, which is a bit surprising IMO:
In [26]: df.loc(axis=1)['a1':'a2']
Out[26]:
Empty DataFrame
Columns: [(a1, b1), (a1, b2), (a1, b3), (a2, b1), (a2, b2), (a2, b3), (a3, b1),
(a3, b2), (a3, b3)]
Index: []
In [27]: df.loc(axis=1)['a1']
...
KeyError: 'the label [a1] is not in the [index]'
Also when having a simple frame, the same observation applies:
In [28]: df2 = pd.DataFrame(np.arange(9).reshape(3,3), columns=['a', 'b', 'c'])
In [29]: df2
Out[29]:
a b c
0 0 1 2
1 3 4 5
2 6 7 8
In [30]: df2.loc(axis=1)['a']
...
KeyError: 'the label [a] is not in the [index]'
The text was updated successfully, but these errors were encountered:
When doing
.loc(axis=1)[...]
, this only works when indexing into multiple levels. Here an example with a MultiIndex column:Given the above, I would expect leaving out the
['b1', 'b2']
to work as well, but in this case it looks like theaxis=1
is ignored, which is a bit surprising IMO:Also when having a simple frame, the same observation applies:
The text was updated successfully, but these errors were encountered: