w3resource

Pandas Series: set_axis() function

Series-set_axis() function

The set_axis() function is used to assign desired index to given axis.
Indexes for column or row labels can be changed by assigning a list-like or Index.
Changed in version 0.21.0: The signature is now labels and axis, consistent with the rest of pandas API. Previously, the axis and labels arguments were respectively the first and second positional arguments.

Syntax:

Series.set_axis(self, labels, axis=0, inplace=None)
Pandas Series set_axis image

Parameters:

Name Description Type/Default Value Required / Optional
labels The values for the new index. list-like, Index Required
axis The axis to update. The value 0 identifies the rows, and 1 identifies the columns. {0 or ‘index’, 1 or ‘columns’}
Default Value: 0
Required
inplace Whether to return a new %(klass)s instance. bool
Default Value: None
Required

Returns: renamed - %(klass)s or None An object of same type as caller if inplace=False, None otherwise.

Example:


Download the above Notebook from here.



Inviting useful, relevant, well-written and unique guest posts