@@ -286,7 +286,7 @@ As usual, **both sides** of the slicers are included as this is label indexing.
286286 names = [' lvl0' , ' lvl1' ])
287287 dfmi = pd.DataFrame(np.arange(len (miindex)* len (micolumns)).reshape((len (miindex),len (micolumns))),
288288 index = miindex,
289- columns = micolumns).sortlevel ().sortlevel (axis = 1 )
289+ columns = micolumns).sort_index ().sort_index (axis = 1 )
290290 dfmi
291291
292292 Basic multi-index slicing using slices, lists, and labels.
@@ -458,7 +458,7 @@ correctly. You can think about breaking the axis into unique groups, where at
458458the hierarchical level of interest, each distinct group shares a label, but no
459459two have the same label. However, the ``MultiIndex `` does not enforce this:
460460**you are responsible for ensuring that things are properly sorted **. There is
461- an important new method ``sortlevel `` to sort an axis within a ``MultiIndex ``
461+ an important new method ``sort_index `` to sort an axis within a ``MultiIndex ``
462462so that its labels are grouped and sorted by the original ordering of the
463463associated factor at that level. Note that this does not necessarily mean the
464464labels will be sorted lexicographically!
@@ -468,34 +468,34 @@ labels will be sorted lexicographically!
468468 import random; random.shuffle(tuples)
469469 s = pd.Series(np.random.randn(8 ), index = pd.MultiIndex.from_tuples(tuples))
470470 s
471- s.sortlevel( 0 )
472- s.sortlevel( 1 )
471+ s.sort_index( level = 0 )
472+ s.sort_index( level = 1 )
473473
474474 .. _advanced.sortlevel_byname :
475475
476- Note, you may also pass a level name to ``sortlevel `` if the MultiIndex levels
476+ Note, you may also pass a level name to ``sort_index `` if the MultiIndex levels
477477are named.
478478
479479.. ipython :: python
480480
481481 s.index.set_names([' L1' , ' L2' ], inplace = True )
482- s.sortlevel (level = ' L1' )
483- s.sortlevel (level = ' L2' )
482+ s.sort_index (level = ' L1' )
483+ s.sort_index (level = ' L2' )
484484
485485 Some indexing will work even if the data are not sorted, but will be rather
486486inefficient and will also return a copy of the data rather than a view:
487487
488488.. ipython :: python
489489
490490 s[' qux' ]
491- s.sortlevel( 1 )[' qux' ]
491+ s.sort_index( level = 1 )[' qux' ]
492492
493493 On higher dimensional objects, you can sort any of the other axes by level if
494494they have a MultiIndex:
495495
496496.. ipython :: python
497497
498- df.T.sortlevel( 1 , axis = 1 )
498+ df.T.sort_index( level = 1 , axis = 1 )
499499
500500 The ``MultiIndex `` object has code to **explicity check the sort depth **. Thus,
501501if you try to index at a depth at which the index is not sorted, it will raise
0 commit comments