pandas.Series.set_axis

pandas 3.1.1 · Series and accessors · method

Replace all labels on an axis with a new collection of equal length.

Call syntax

Series.set_axis(labels, *, axis=0, copy=…)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
labels Required
Positional or keyword
list-like or Index

Provide the labels used for selecting rows, renaming entries, or naming bins.

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.

Returns

Series