pandas.Series.rename_axis

pandas 3.1.1 · Series and accessors · method

Change the name of an axis while preserving its labels.

Call syntax

Series.rename_axis(mapper=…, *, index=…, axis=0, copy=…, inplace=…)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
mapper Optional
Positional or keyword
scalar, list-like

Provide a dictionary or callable that maps input values or labels.

index Optional
Keyword only
scalar, list-like, dict-like or function

Supply row labels or control how existing row labels are used.

axis Optional
Keyword only
Default 0
{0 or 'index'}

Choose which axis the operation acts on. The accepted axis labels depend on the receiver.

copy Optional
Keyword only
bool

Control whether data is copied where the API supports that choice.

inplace Optional
Keyword only
bool

Choose whether to change the existing object. Where supported, an in-place call typically returns None.

Returns

Series, or None