File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -3103,6 +3103,21 @@ def _reorder_indexer(
3103
3103
-------
3104
3104
indexer : a sorted Int64Index indexer of self ordered as seq
3105
3105
"""
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
+
3106
3121
n = len (self )
3107
3122
keys : Tuple [np .ndarray , ...] = tuple ()
3108
3123
# For each level of the sequence in seq, map the level codes with the
You can’t perform that action at this time.
0 commit comments