pandas.Series.droplevel

pandas 3.1.1 · Series and accessors · method

Remove one or more levels of a hierarchical index.

Call syntax

Series.droplevel(level, axis=0)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
level Required
Positional or keyword
int, str, or list-like

Choose an index level by name or integer position.

axis Optional
Positional or keyword
Default 0
{0 or 'index', 1 or 'columns'}

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

Returns

Series/DataFrame