File tree 1 file changed +14
-13
lines changed
1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -3071,19 +3071,20 @@ def _reorder_indexer(
3071
3071
-------
3072
3072
indexer : a sorted Int64Index indexer of self ordered as seq
3073
3073
"""
3074
- # Find out if the list_like label are sorted as the levels or not
3075
- need_sort = False
3076
- for i , k in enumerate (seq ):
3077
- if is_list_like (k ):
3078
- if not need_sort :
3079
- k_codes = self .levels [i ].get_indexer (k )
3080
- k_codes = k_codes [k_codes >= 0 ] # Filter absent keys
3081
- # True if the given codes are not ordered
3082
- need_sort = (k_codes [:- 1 ] > k_codes [1 :]).any ()
3083
- # Bail out if no need to sort
3084
- # This is only true for a lexsorted index
3085
- if not need_sort and self .is_lexsorted ():
3086
- return indexer
3074
+ # If the index is lexsorted and the list_like label in seq are sorted
3075
+ # then we do not need to sort
3076
+ if self .is_lexsorted ():
3077
+ need_sort = False
3078
+ for i , k in enumerate (seq ):
3079
+ if is_list_like (k ):
3080
+ if not need_sort :
3081
+ k_codes = self .levels [i ].get_indexer (k )
3082
+ k_codes = k_codes [k_codes >= 0 ] # Filter absent keys
3083
+ # True if the given codes are not ordered
3084
+ need_sort = (k_codes [:- 1 ] > k_codes [1 :]).any ()
3085
+ # Bail out if both index and seq are sorted
3086
+ if not need_sort :
3087
+ return indexer
3087
3088
3088
3089
n = len (self )
3089
3090
keys : Tuple [np .ndarray , ...] = tuple ()
You can’t perform that action at this time.
0 commit comments