Pandas DataFrame: rename_axis() function

DataFrame - rename_axis() function

The rename_axis() function is used to set the name of the axis for the index or columns.


DataFrame.rename_axis(self, mapper=None, index=None, columns=None, axis=None, copy=True, inplace=False)


Name Description Type/Default Value Required / Optional

Value to set the axis name attribute.

scalar, list-like Optional
index, columns A scalar, list-like, dict-like or functions transformations to apply to that axis’ values.
Use either mapper and axis to specify the axis to target with mapper, or index and/or columns
scalar, list-like, dict-like or function Optional
axis    The axis to rename. {0 or ‘index’, 1 or ‘columns’}
Default Value: 0
copy    Also copy underlying data. bool
Default Value: True
inplace  Modifies the object directly, instead of creating a new Series or DataFrame. bool
Default Value: False

Returns: Series, DataFrame, or None
The same type as the caller or None if inplace is True.


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - rename() function
Next: DataFrame - sample() function

Follow us on Facebook and Twitter for latest update.