Skip to content

Commit 06384b7

Browse files
authored
CLN: Unreachable branch in Loc._getitem_iterable (#31636)
1 parent 106ed85 commit 06384b7

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

pandas/core/indexing.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,14 +1477,12 @@ def _get_listlike_indexer(self, key, axis: int, raise_missing: bool = False):
14771477

14781478
def _getitem_iterable(self, key, axis: int):
14791479
"""
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.
14831481
14841482
Parameters
14851483
----------
14861484
key : iterable
1487-
Targeted labels or boolean indexer.
1485+
Targeted labels.
14881486
axis: int
14891487
Dimension on which the indexing is being made.
14901488
@@ -1493,30 +1491,20 @@ def _getitem_iterable(self, key, axis: int):
14931491
KeyError
14941492
If no key was found. Will change in the future to raise if not all
14951493
keys were found.
1496-
IndexingError
1497-
If the boolean indexer is unalignable with the object being
1498-
indexed.
14991494
15001495
Returns
15011496
-------
15021497
scalar, DataFrame, or Series: indexed value(s).
15031498
"""
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.
15051501
self._validate_key(key, axis)
15061502

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+
)
15201508

15211509
def _validate_read_indexer(
15221510
self, key, indexer, axis: int, raise_missing: bool = False
@@ -2055,11 +2043,8 @@ def _convert_to_indexer(self, key, axis: int):
20552043
elif is_float(key):
20562044
return self._convert_scalar_indexer(key, axis)
20572045

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
20632048

20642049

20652050
class _ScalarAccessIndexer(_NDFrameIndexerBase):

0 commit comments

Comments
 (0)