@@ -3968,26 +3968,44 @@ def nsmallest(
3968
3968
"""
3969
3969
return selectn .SelectNSeries (self , n = n , keep = keep ).nsmallest ()
3970
3970
3971
- @ doc (
3972
- klass = _shared_doc_kwargs [ "klass" ],
3973
- extra_params = dedent (
3974
- """copy : bool, default True
3975
- Whether to copy underlying data .
3971
+ def swaplevel (
3972
+ self , i : Level = - 2 , j : Level = - 1 , copy : bool | lib . NoDefault = lib . no_default
3973
+ ) -> Series :
3974
+ """
3975
+ Swap levels i and j in a :class:`MultiIndex` .
3976
3976
3977
- .. note::
3978
- The `copy` keyword will change behavior in pandas 3.0.
3979
- `Copy-on-Write
3980
- <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
3981
- will be enabled by default, which means that all methods with a
3982
- `copy` keyword will use a lazy copy mechanism to defer the copy and
3983
- ignore the `copy` keyword. The `copy` keyword will be removed in a
3984
- future version of pandas.
3977
+ Default is to swap the two innermost levels of the index.
3978
+
3979
+ Parameters
3980
+ ----------
3981
+ i, j : int or str
3982
+ Levels of the indices to be swapped. Can pass level name as string.
3983
+ copy : bool, default True
3984
+ Whether to copy underlying data.
3985
+
3986
+ .. note::
3987
+ The `copy` keyword will change behavior in pandas 3.0.
3988
+ `Copy-on-Write
3989
+ <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
3990
+ will be enabled by default, which means that all methods with a
3991
+ `copy` keyword will use a lazy copy mechanism to defer the copy
3992
+ and ignore the `copy` keyword. The `copy` keyword will be
3993
+ removed in a future version of pandas.
3994
+
3995
+ You can already get the future behavior and improvements through
3996
+ enabling copy on write ``pd.options.mode.copy_on_write = True``
3997
+
3998
+ Returns
3999
+ -------
4000
+ Series
4001
+ Series with levels swapped in MultiIndex.
4002
+
4003
+ See Also
4004
+ --------
4005
+ DataFrame.swaplevel : Swap levels i and j in a :class:`DataFrame`.
4006
+ Series.reorder_levels : Rearrange index levels using input order.
4007
+ MultiIndex.swaplevel : Swap levels i and j in a :class:`MultiIndex`.
3985
4008
3986
- You can already get the future behavior and improvements through
3987
- enabling copy on write ``pd.options.mode.copy_on_write = True``"""
3988
- ),
3989
- examples = dedent (
3990
- """\
3991
4009
Examples
3992
4010
--------
3993
4011
>>> s = pd.Series(
@@ -4037,29 +4055,7 @@ def nsmallest(
4037
4055
Geography Final exam February B
4038
4056
History Coursework March A
4039
4057
Geography Coursework April C
4040
- dtype: object"""
4041
- ),
4042
- )
4043
- def swaplevel (
4044
- self , i : Level = - 2 , j : Level = - 1 , copy : bool | lib .NoDefault = lib .no_default
4045
- ) -> Series :
4046
- """
4047
- Swap levels i and j in a :class:`MultiIndex`.
4048
-
4049
- Default is to swap the two innermost levels of the index.
4050
-
4051
- Parameters
4052
- ----------
4053
- i, j : int or str
4054
- Levels of the indices to be swapped. Can pass level name as string.
4055
- {extra_params}
4056
-
4057
- Returns
4058
- -------
4059
- {klass}
4060
- {klass} with levels swapped in MultiIndex.
4061
-
4062
- {examples}
4058
+ dtype: object
4063
4059
"""
4064
4060
self ._check_copy_deprecation (copy )
4065
4061
assert isinstance (self .index , MultiIndex )
0 commit comments