pandas.Series.squeeze

pandas 3.1.1 · Series and accessors · method

Collapse axes of length one, yielding a lower-dimensional object or scalar where possible.

Call syntax

Series.squeeze(axis=None)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
axis Optional
Positional or keyword
Default None
{0 or 'index', 1 or 'columns', None}

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

Returns

DataFrame, Series, or scalar