Skip to content

Commit 1f2f385

Browse files
committed
BUG: Fix indexing MultiIndex with Series with 0 not index
1 parent f65a641 commit 1f2f385

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pandas/core/indexing.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1525,11 +1525,20 @@ def _getitem_axis(self, key, axis=0):
15251525
# possibly convert a list-like into a nested tuple
15261526
# but don't convert a list-like of tuples
15271527
if isinstance(labels, MultiIndex):
1528+
if isinstance(key, ABCSeries):
1529+
# GH 14730
1530+
key = key.values.tolist()
1531+
elif isinstance(key, ABCDataFrame):
1532+
# GH 15438
1533+
raise NotImplementedError("Indexing a MultiIndex with a "
1534+
"DataFrame key is not "
1535+
"implemented")
1536+
elif hasattr(key, 'ndim') and key.ndim > 1:
1537+
raise NotImplementedError("Indexing a MultiIndex with a "
1538+
"multidimensional key is not "
1539+
"implemented")
15281540
if (not isinstance(key, tuple) and len(key) > 1 and
15291541
not isinstance(key[0], tuple)):
1530-
if isinstance(key, ABCSeries):
1531-
# GH 14730
1532-
key = list(key)
15331542
key = tuple([key])
15341543

15351544
# an iterable multi-selection

0 commit comments

Comments
 (0)