@@ -1477,14 +1477,12 @@ def _get_listlike_indexer(self, key, axis: int, raise_missing: bool = False):
1477
1477
1478
1478
def _getitem_iterable (self , key , axis : int ):
1479
1479
"""
1480
- Index current object with an an iterable key.
1481
-
1482
- The iterable key can be a boolean indexer or a collection of keys.
1480
+ Index current object with an an iterable collection of keys.
1483
1481
1484
1482
Parameters
1485
1483
----------
1486
1484
key : iterable
1487
- Targeted labels or boolean indexer .
1485
+ Targeted labels.
1488
1486
axis: int
1489
1487
Dimension on which the indexing is being made.
1490
1488
@@ -1493,30 +1491,20 @@ def _getitem_iterable(self, key, axis: int):
1493
1491
KeyError
1494
1492
If no key was found. Will change in the future to raise if not all
1495
1493
keys were found.
1496
- IndexingError
1497
- If the boolean indexer is unalignable with the object being
1498
- indexed.
1499
1494
1500
1495
Returns
1501
1496
-------
1502
1497
scalar, DataFrame, or Series: indexed value(s).
1503
1498
"""
1504
- # caller is responsible for ensuring non-None axis
1499
+ # we assume that not com.is_bool_indexer(key), as that is
1500
+ # handled before we get here.
1505
1501
self ._validate_key (key , axis )
1506
1502
1507
- labels = self .obj ._get_axis (axis )
1508
-
1509
- if com .is_bool_indexer (key ):
1510
- # A boolean indexer
1511
- key = check_bool_indexer (labels , key )
1512
- (inds ,) = key .nonzero ()
1513
- return self .obj ._take_with_is_copy (inds , axis = axis )
1514
- else :
1515
- # A collection of keys
1516
- keyarr , indexer = self ._get_listlike_indexer (key , axis , raise_missing = False )
1517
- return self .obj ._reindex_with_indexers (
1518
- {axis : [keyarr , indexer ]}, copy = True , allow_dups = True
1519
- )
1503
+ # A collection of keys
1504
+ keyarr , indexer = self ._get_listlike_indexer (key , axis , raise_missing = False )
1505
+ return self .obj ._reindex_with_indexers (
1506
+ {axis : [keyarr , indexer ]}, copy = True , allow_dups = True
1507
+ )
1520
1508
1521
1509
def _validate_read_indexer (
1522
1510
self , key , indexer , axis : int , raise_missing : bool = False
@@ -2055,11 +2043,8 @@ def _convert_to_indexer(self, key, axis: int):
2055
2043
elif is_float (key ):
2056
2044
return self ._convert_scalar_indexer (key , axis )
2057
2045
2058
- try :
2059
- self ._validate_key (key , axis )
2060
- return key
2061
- except ValueError :
2062
- raise ValueError (f"Can only index by location with a [{ self ._valid_types } ]" )
2046
+ self ._validate_key (key , axis )
2047
+ return key
2063
2048
2064
2049
2065
2050
class _ScalarAccessIndexer (_NDFrameIndexerBase ):
0 commit comments