Skip to content

Commit 0c3314d

Browse files
authored
PERF: nsmallest (#43696)
1 parent 849d38a commit 0c3314d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/core/indexes/base.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -6351,8 +6351,11 @@ def drop(self, labels, errors: str_t = "raise") -> Index:
63516351
KeyError
63526352
If not all of the labels are found in the selected axis
63536353
"""
6354-
arr_dtype = "object" if self.dtype == "object" else None
6355-
labels = com.index_labels_to_array(labels, dtype=arr_dtype)
6354+
if not isinstance(labels, Index):
6355+
# avoid materializing e.g. RangeIndex
6356+
arr_dtype = "object" if self.dtype == "object" else None
6357+
labels = com.index_labels_to_array(labels, dtype=arr_dtype)
6358+
63566359
indexer = self.get_indexer_for(labels)
63576360
mask = indexer == -1
63586361
if mask.any():

0 commit comments

Comments
 (0)