Pandas Series: rename() function

Alter Series index in Pandas

The rename() function is used to alter Series index labels or name.

Function / dict values must be unique (1-to-1). Labels not contained in a dict / Series will be left as-is. Extra labels listed don’t throw an error.

Alternatively, change Series.name with a scalar value.


Series.rename(self, index=None, **kwargs)
Pandas Series rename image


Name Description Type/Default Value Required / Optional
index dict-like or functions are transformations to apply to the index. Scalar or hashable sequence-like will alter the Series.name attribute. scalar, hashable sequence, dict-like or function optional
copy Whether to copy underlying data. bool
Default Value: True
inplace Whether to return a new Series. If True then value of copy is ignored. bool
Default Value: False
level In case of a MultiIndex, only rename labels in the specified level. int or level name
Default Value: None

Returns: Series
Series with index labels or name altered.


Download the above Notebook from here.

Previous: Object with matching indices as other object in Pandas
Next: Set the name of the axis in Pandas