@@ -950,20 +950,25 @@ def f(x):
950
950
rename .__doc__ = _shared_docs ['rename' ]
951
951
952
952
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.
954
955
955
956
Parameters
956
957
----------
957
958
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.
960
962
copy : boolean, default True
961
- Also copy underlying data
963
+ Also copy underlying data.
962
964
inplace : boolean, default False
965
+ Modifies the object directly, instead of creating a new Series
966
+ or DataFrame.
963
967
964
968
Returns
965
969
-------
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.
967
972
968
973
Notes
969
974
-----
@@ -974,11 +979,23 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False):
974
979
975
980
See Also
976
981
--------
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
979
985
980
986
Examples
981
987
--------
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**
982
999
983
1000
>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
984
1001
>>> df.rename_axis("foo")
@@ -993,7 +1010,6 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False):
993
1010
0 1 4
994
1011
1 2 5
995
1012
2 3 6
996
-
997
1013
"""
998
1014
inplace = validate_bool_kwarg (inplace , 'inplace' )
999
1015
non_mapper = is_scalar (mapper ) or (is_list_like (mapper ) and not
0 commit comments