Skip to content

Commit 76a87ca

Browse files
xrmxTomAugspurger
authored andcommitted
DOC: update pandas.Series.rename_axis (#20137)
1 parent 823b5d3 commit 76a87ca

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

pandas/core/generic.py

+24-8
Original file line numberDiff line numberDiff line change
@@ -950,20 +950,25 @@ def f(x):
950950
rename.__doc__ = _shared_docs['rename']
951951

952952
def rename_axis(self, mapper, axis=0, copy=True, inplace=False):
953-
"""Alter the name of the index or columns.
953+
"""
954+
Alter the name of the index or columns.
954955
955956
Parameters
956957
----------
957958
mapper : scalar, list-like, optional
958-
Value to set the axis name attribute.
959-
axis : int or string, default 0
959+
Value to set as the axis name attribute.
960+
axis : {0 or 'index', 1 or 'columns'}, default 0
961+
The index or the name of the axis.
960962
copy : boolean, default True
961-
Also copy underlying data
963+
Also copy underlying data.
962964
inplace : boolean, default False
965+
Modifies the object directly, instead of creating a new Series
966+
or DataFrame.
963967
964968
Returns
965969
-------
966-
renamed : type of caller or None if inplace=True
970+
renamed : Series, DataFrame, or None
971+
The same type as the caller or None if `inplace` is True.
967972
968973
Notes
969974
-----
@@ -974,11 +979,23 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False):
974979
975980
See Also
976981
--------
977-
pandas.Series.rename, pandas.DataFrame.rename
978-
pandas.Index.rename
982+
pandas.Series.rename : Alter Series index labels or name
983+
pandas.DataFrame.rename : Alter DataFrame index labels or name
984+
pandas.Index.rename : Set new names on index
979985
980986
Examples
981987
--------
988+
**Series**
989+
990+
>>> s = pd.Series([1, 2, 3])
991+
>>> s.rename_axis("foo")
992+
foo
993+
0 1
994+
1 2
995+
2 3
996+
dtype: int64
997+
998+
**DataFrame**
982999
9831000
>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
9841001
>>> df.rename_axis("foo")
@@ -993,7 +1010,6 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False):
9931010
0 1 4
9941011
1 2 5
9951012
2 3 6
996-
9971013
"""
9981014
inplace = validate_bool_kwarg(inplace, 'inplace')
9991015
non_mapper = is_scalar(mapper) or (is_list_like(mapper) and not

0 commit comments

Comments
 (0)