File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,8 @@ Performance improvements
70
70
~~~~~~~~~~~~~~~~~~~~~~~~
71
71
72
72
- Performance improvement in indexing with a non-unique :class: `IntervalIndex ` (:issue: `27489 `)
73
- -
73
+ - Performance improvement in `MultiIndex.is_monotonic ` (:issue: `27495 `)
74
+
74
75
75
76
.. _whatsnew_1000.bug_fixes :
76
77
Original file line number Diff line number Diff line change @@ -1359,6 +1359,12 @@ def is_monotonic_increasing(self):
1359
1359
increasing) values.
1360
1360
"""
1361
1361
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
+
1362
1368
# reversed() because lexsort() wants the most significant key last.
1363
1369
values = [
1364
1370
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