File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,8 @@ Performance improvements
7070~~~~~~~~~~~~~~~~~~~~~~~~ 
7171
7272- Performance improvement in indexing with a non-unique :class: `IntervalIndex ` (:issue: `27489 `)
73- -
73+ - Performance improvement in `MultiIndex.is_monotonic ` (:issue: `27495 `)
74+ 
7475
7576.. _whatsnew_1000.bug_fixes :
7677
Original file line number Diff line number Diff line change @@ -1359,6 +1359,12 @@ def is_monotonic_increasing(self):
13591359 increasing) values. 
13601360 """ 
13611361
1362+  if  all (x .is_monotonic  for  x  in  self .levels ):
1363+  # If each level is sorted, we can operate on the codes directly. GH27495 
1364+  return  libalgos .is_lexsorted (
1365+  [x .astype ("int64" , copy = False ) for  x  in  self .codes ]
1366+  )
1367+ 
13621368 # reversed() because lexsort() wants the most significant key last. 
13631369 values  =  [
13641370 self ._get_level_values (i ).values  for  i  in  reversed (range (len (self .levels )))
                         You can’t perform that action at this time. 
           
                  
0 commit comments