@@ -1173,14 +1173,15 @@ def from_product(cls, iterables, sortorder=None, names=None):
11731173 labels = cartesian_product (labels )
11741174 return MultiIndex (levels , labels , sortorder = sortorder , names = names )
11751175
1176- def sort_monotonic (self ):
1176+ def sort_levels_monotonic (self ):
11771177 """
11781178 .. versionadded:: 0.20.0
11791179
11801180 This is an *internal* function.
11811181
11821182 create a new MultiIndex from the current to monotonically sorted
1183- items IN the levels
1183+ items IN the levels. This does not actually make the entire MultiIndex
1184+ monotonic, JUST the levels.
11841185
11851186 The resulting MultiIndex will have the same outward
11861187 appearance, meaning the same .values and ordering. It will also
@@ -1190,6 +1191,19 @@ def sort_monotonic(self):
11901191 -------
11911192 MultiIndex
11921193
1194+ Examples
1195+ --------
1196+
1197+ >>> i = pd.MultiIndex(levels=[['a', 'b'], ['bb', 'aa']],
1198+ labels=[[0, 0, 1, 1], [0, 1, 0, 1]])
1199+ >>> i
1200+ MultiIndex(levels=[['a', 'b'], ['bb', 'aa']],
1201+ labels=[[0, 0, 1, 1], [0, 1, 0, 1]])
1202+
1203+ >>> i.sort_monotonic()
1204+ MultiIndex(levels=[['a', 'b'], ['aa', 'bb']],
1205+ labels=[[0, 0, 1, 1], [1, 0, 1, 0]])
1206+
11931207 """
11941208
11951209 if self .is_lexsorted () and self .is_monotonic :
@@ -1237,7 +1251,7 @@ def remove_unused_levels(self):
12371251
12381252 Examples
12391253 --------
1240- >>> i = MultiIndex.from_product([range(2), list('ab')])
1254+ >>> i = pd. MultiIndex.from_product([range(2), list('ab')])
12411255 MultiIndex(levels=[[0, 1], ['a', 'b']],
12421256 labels=[[0, 0, 1, 1], [0, 1, 0, 1]])
12431257
0 commit comments