Series.rename_axis(mapper, axis=0, copy=True, inplace=False)
[source]
Alter the name of the index or columns.
Parameters: |
mapper : scalar, list-like, optional Value to set the axis name attribute. axis : int or string, default 0 copy : boolean, default True Also copy underlying data inplace : boolean, default False |
---|---|
Returns: |
renamed : type of caller or None if inplace=True |
Prior to version 0.21.0, rename_axis
could also be used to change the axis labels by passing a mapping or scalar. This behavior is deprecated and will be removed in a future version. Use rename
instead.
>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) >>> df.rename_axis("foo") A B foo 0 1 4 1 2 5 2 3 6
>>> df.rename_axis("bar", axis="columns") bar A B 0 1 4 1 2 5 2 3 6
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.22.0/generated/pandas.Series.rename_axis.html