@@ -1653,6 +1653,30 @@ def is_lexsorted(self) -> bool:
1653
1653
Returns
1654
1654
-------
1655
1655
bool
1656
+
1657
+ Examples
1658
+ --------
1659
+ In the below examples, the first level of the MultiIndex is sorted because
1660
+ a<b<c, so there is no need to look at the next level.
1661
+
1662
+ >>> pd.MultiIndex.from_arrays([['a', 'b', 'c'], ['d', 'e', 'f']]).is_lexsorted()
1663
+ True
1664
+ >>> pd.MultiIndex.from_arrays([['a', 'b', 'c'], ['d', 'f', 'e']]).is_lexsorted()
1665
+ True
1666
+
1667
+ In case there is a tie, the lexicographical sorting looks
1668
+ at the next level of the MultiIndex.
1669
+
1670
+ >>> pd.MultiIndex.from_arrays([[0, 1, 1], ['a', 'b', 'c']]).is_lexsorted()
1671
+ True
1672
+ >>> pd.MultiIndex.from_arrays([[0, 1, 1], ['a', 'c', 'b']]).is_lexsorted()
1673
+ False
1674
+ >>> pd.MultiIndex.from_arrays([['a', 'a', 'b', 'b'],
1675
+ ... ['aa', 'bb', 'aa', 'bb']]).is_lexsorted()
1676
+ True
1677
+ >>> pd.MultiIndex.from_arrays([['a', 'a', 'b', 'b'],
1678
+ ... ['bb', 'aa', 'aa', 'bb']]).is_lexsorted()
1679
+ False
1656
1680
"""
1657
1681
return self .lexsort_depth == self .nlevels
1658
1682
0 commit comments