@@ -1511,37 +1511,28 @@ def _getitem_axis(self, key, axis=0):
1511
1511
elif is_bool_indexer (key ):
1512
1512
return self ._getbool_axis (key , axis = axis )
1513
1513
elif is_list_like_indexer (key ):
1514
+ if isinstance (key , ABCDataFrame ):
1515
+ # GH 15438
1516
+ raise NotImplementedError ("Indexing a with a DataFrame key is "
1517
+ "not implemented" )
1518
+ elif hasattr (key , 'ndim' ) and key .ndim > 1 :
1519
+ raise NotImplementedError ("Indexing with a multidimensional "
1520
+ "key is not implemented" )
1514
1521
1515
1522
# convert various list-like indexers
1516
1523
# to a list of keys
1517
1524
# we will use the *values* of the object
1518
1525
# and NOT the index if its a PandasObject
1519
1526
if isinstance (labels , MultiIndex ):
1520
-
1521
- if isinstance (key , (ABCSeries , np .ndarray )) and key .ndim <= 1 :
1522
- # Series, or 0,1 ndim ndarray
1527
+ if isinstance (key , (ABCSeries , np .ndarray )) and key .ndim != 1 :
1528
+ # Series or 1-dim ndarray
1523
1529
# GH 14730
1524
1530
key = list (key )
1525
- elif isinstance (key , ABCDataFrame ):
1526
- # GH 15438
1527
- raise NotImplementedError ("Indexing a MultiIndex with a "
1528
- "DataFrame key is not "
1529
- "implemented" )
1530
- elif hasattr (key , 'ndim' ) and key .ndim > 1 :
1531
- raise NotImplementedError ("Indexing a MultiIndex with a "
1532
- "multidimensional key is not "
1533
- "implemented" )
1534
-
1535
- if (not isinstance (key , tuple ) and len (key ) > 1 and
1536
- not isinstance (key [0 ], tuple )):
1537
- key = tuple ([key ])
1531
+ if not isinstance (key , tuple ):
1532
+ return self ._getitem_iterable (key , axis = axis )
1538
1533
1539
1534
# an iterable multi-selection
1540
- if not (isinstance (key , tuple ) and isinstance (labels , MultiIndex )):
1541
-
1542
- if hasattr (key , 'ndim' ) and key .ndim > 1 :
1543
- raise ValueError ('Cannot index with multidimensional key' )
1544
-
1535
+ else :
1545
1536
return self ._getitem_iterable (key , axis = axis )
1546
1537
1547
1538
# nested tuple slicing
0 commit comments