Skip to content

Commit bf4e74d

Browse files
authored
CLN: Use self.loc for Series __getitem__ with IntervalIndex (#31830)
1 parent 11f1500 commit bf4e74d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pandas/core/series.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,11 +916,12 @@ def _get_with(self, key):
916916
# Note: The key_type == "boolean" case should be caught by the
917917
# com.is_bool_indexer check in __getitem__
918918
if key_type == "integer":
919+
# We need to decide whether to treat this as a positional indexer
920+
# (i.e. self.iloc) or label-based (i.e. self.loc)
919921
if self.index.is_integer() or self.index.is_floating():
920922
return self.loc[key]
921923
elif isinstance(self.index, IntervalIndex):
922-
indexer = self.index.get_indexer_for(key)
923-
return self.iloc[indexer]
924+
return self.loc[key]
924925
else:
925926
return self.iloc[key]
926927

0 commit comments

Comments
 (0)