Skip to content

Commit 9b3e84d

Browse files
committed
PERF: speed up MultiIndex.is_monotonic by 50x
1 parent 5bd57f9 commit 9b3e84d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pandas/core/indexes/multi.py

+3
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,9 @@ def is_monotonic_increasing(self):
13591359
increasing) values.
13601360
"""
13611361

1362+
if all([x.is_monotonic for x in self.levels]):
1363+
return libalgos.is_lexsorted([x.astype("int64") for x in self.codes])
1364+
13621365
# reversed() because lexsort() wants the most significant key last.
13631366
values = [
13641367
self._get_level_values(i).values for i in reversed(range(len(self.levels)))

0 commit comments

Comments
 (0)