Skip to content

Commit 3367109

Browse files
committed
Revert "PERF: Delete flag for sorting multiindex loc call."
This reverts commit 7fee53c.
1 parent 82e5109 commit 3367109

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
@@ -3103,6 +3103,21 @@ def _reorder_indexer(
31033103
-------
31043104
indexer : a sorted Int64Index indexer of self ordered as seq
31053105
"""
3106+
# If the index is lexsorted and the list_like label in seq are sorted
3107+
# then we do not need to sort
3108+
if self.is_lexsorted():
3109+
need_sort = False
3110+
for i, k in enumerate(seq):
3111+
if is_list_like(k):
3112+
if not need_sort:
3113+
k_codes = self.levels[i].get_indexer(k)
3114+
k_codes = k_codes[k_codes >= 0] # Filter absent keys
3115+
# True if the given codes are not ordered
3116+
need_sort = (k_codes[:-1] > k_codes[1:]).any()
3117+
# Bail out if both index and seq are sorted
3118+
if not need_sort:
3119+
return indexer
3120+
31063121
n = len(self)
31073122
keys: Tuple[np.ndarray, ...] = tuple()
31083123
# For each level of the sequence in seq, map the level codes with the

0 commit comments

Comments
 (0)