@@ -7642,16 +7642,30 @@ def nsmallest(
76427642 """
76437643 return selectn .SelectNFrame (self , n = n , keep = keep , columns = columns ).nsmallest ()
76447644
7645- @doc (
7646- Series .swaplevel ,
7647- klass = _shared_doc_kwargs ["klass" ],
7648- extra_params = dedent (
7649- """axis : {0 or 'index', 1 or 'columns'}, default 0
7650- The axis to swap levels on. 0 or 'index' for row-wise, 1 or
7651- 'columns' for column-wise."""
7652- ),
7653- examples = dedent (
7654- """\
7645+ def swaplevel (self , i : Axis = - 2 , j : Axis = - 1 , axis : Axis = 0 ) -> DataFrame :
7646+ """
7647+ Swap levels i and j in a :class:`MultiIndex`.
7648+
7649+ Default is to swap the two innermost levels of the index.
7650+
7651+ Parameters
7652+ ----------
7653+ i, j : int or str
7654+ Levels of the indices to be swapped. Can pass level name as string.
7655+ axis : {0 or 'index', 1 or 'columns'}, default 0
7656+ The axis to swap levels on. 0 or 'index' for row-wise, 1 or
7657+ 'columns' for column-wise.
7658+
7659+ Returns
7660+ -------
7661+ DataFrame
7662+ DataFrame with levels swapped in MultiIndex.
7663+
7664+ See Also
7665+ --------
7666+ DataFrame.reorder_levels: Reorder levels of MultiIndex.
7667+ DataFrame.sort_index: Sort MultiIndex.
7668+
76557669 Examples
76567670 --------
76577671 >>> df = pd.DataFrame(
@@ -7701,10 +7715,8 @@ def nsmallest(
77017715 History Final exam January A
77027716 Geography Final exam February B
77037717 History Coursework March A
7704- Geography Coursework April C"""
7705- ),
7706- )
7707- def swaplevel (self , i : Axis = - 2 , j : Axis = - 1 , axis : Axis = 0 ) -> DataFrame :
7718+ Geography Coursework April C
7719+ """
77087720 result = self .copy (deep = False )
77097721
77107722 axis = self ._get_axis_number (axis )
0 commit comments