@@ -7642,16 +7642,30 @@ def nsmallest(
7642
7642
"""
7643
7643
return selectn .SelectNFrame (self , n = n , keep = keep , columns = columns ).nsmallest ()
7644
7644
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
+
7655
7669
Examples
7656
7670
--------
7657
7671
>>> df = pd.DataFrame(
@@ -7701,10 +7715,8 @@ def nsmallest(
7701
7715
History Final exam January A
7702
7716
Geography Final exam February B
7703
7717
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
+ """
7708
7720
result = self .copy (deep = False )
7709
7721
7710
7722
axis = self ._get_axis_number (axis )
0 commit comments