w3resource

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.

Syntax:

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

Parameters:

Name Description Type/Default Value Required / Optional
mapper                       

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
Required
copy    Also copy underlying data. bool
Default Value: True
Required
inplace  Modifies the object directly, instead of creating a new Series or DataFrame. bool
Default Value: False
Required

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

Example:


Download the Pandas DataFrame Notebooks from here.

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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/dataframe/dataframe-rename_axis.php