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 @@ -3074,6 +3074,21 @@ def _reorder_indexer(
3074
3074
-------
3075
3075
indexer : a sorted Int64Index indexer of self ordered as seq
3076
3076
"""
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
+
3077
3092
n = len (self )
3078
3093
keys : Tuple [np .ndarray , ...] = tuple ()
3079
3094
# 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