Set the name of the axis for the index or columns.
Parameters:
mapper : scalar, list-like, optional
Value to set the axis name attribute.
index, columns : scalar, list-like, dict-like or function, optional
A scalar, list-like, dict-like or functions transformations to
apply to that axis’ values.
Note that the columns parameter is not allowed if the
object is a Series. This parameter only apply for DataFrame
type objects.
Use either mapper and axis to
specify the axis to target with mapper, or index
and/or columns.
axis : {0 or ‘index’, 1 or ‘columns’}, default 0
The axis to rename. For Series this parameter is unused and defaults to 0.
copy : bool, default None
Also copy underlying data.
inplace : bool, default False
Modifies the object directly, instead of creating a new Series
or DataFrame.
Returns:
Series, DataFrame, or None
The same type as the caller or None if inplace=True.
Notes
DataFrame.rename_axis supports two calling conventions
(index=index_mapper,columns=columns_mapper,...)
(mapper,axis={'index','columns'},...)
The first calling convention will only modify the names of
the index and/or the names of the Index object that is the columns.
In this case, the parameter copy is ignored.
The second calling convention will modify the names of the
corresponding index if mapper is a list or a scalar.
However, if mapper is dict-like or a function, it will use the
deprecated behavior of modifying the axis labels.
We highly recommend using keyword arguments to clarify your
intent.