Skip to content

Commit 4b7c76d

Browse files
committed
Revert "PERF: Delete flag for sorting multiindex loc call."
This reverts commit 7fee53c.
1 parent d816b1f commit 4b7c76d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/core/indexes/multi.py

+15
Original file line numberDiff line numberDiff line change
@@ -3074,6 +3074,21 @@ def _reorder_indexer(
30743074
-------
30753075
indexer : a sorted Int64Index indexer of self ordered as seq
30763076
"""
3077+
# If the index is lexsorted and the list_like label in seq are sorted
3078+
# then we do not need to sort
3079+
if self.is_lexsorted():
3080+
need_sort = False
3081+
for i, k in enumerate(seq):
3082+
if is_list_like(k):
3083+
if not need_sort:
3084+
k_codes = self.levels[i].get_indexer(k)
3085+
k_codes = k_codes[k_codes >= 0] # Filter absent keys
3086+
# True if the given codes are not ordered
3087+
need_sort = (k_codes[:-1] > k_codes[1:]).any()
3088+
# Bail out if both index and seq are sorted
3089+
if not need_sort:
3090+
return indexer
3091+
30773092
n = len(self)
30783093
keys: Tuple[np.ndarray, ...] = tuple()
30793094
# For each level of the sequence in seq, map the level codes with the

0 commit comments

Comments
 (0)