pandas 1.4.2

ParametersReturnsBackRef
rename(self, index=None, *, axis=None, copy=True, inplace=False, level=None, errors='ignore') -> 'Series | None'

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.

See the user guide <basics.rename> for more.

Parameters

axis : {0 or "index"}

Unused. Accepted for compatibility with DataFrame method only.

index : scalar, hashable sequence, dict-like or function, optional

Functions or dict-like are transformations to apply to the index. Scalar or hashable sequence-like will alter the Series.name attribute.

**kwargs :

Additional keyword arguments passed to the function. Only the "inplace" keyword is used.

Returns

Series or None

Series with index labels or name altered or None if inplace=True .

Alter Series index labels or name.

See Also

DataFrame.rename

Corresponding DataFrame method.

Series.rename_axis

Set the name of the axis.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([1, 2, 3])
... s 0 1 1 2 2 3 dtype: int64
This example is valid syntax, but we were not able to check execution
>>> s.rename("my_name")  # scalar, changes Series.name
0    1
1    2
2    3
Name: my_name, dtype: int64
This example is valid syntax, but we were not able to check execution
>>> s.rename(lambda x: x ** 2)  # function, changes labels
0    1
1    2
4    3
dtype: int64
This example is valid syntax, but we were not able to check execution
>>> s.rename({1: 3, 2: 5})  # mapping, changes labels
0    1
3    2
5    3
dtype: int64
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.generic.NDFrame.rename_axis pandas.core.generic.NDFrame._set_axis_name

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/series.py#4527
type: <class 'function'>
Commit: