pandas.api.typing.SeriesGroupBy.ngroup

pandas 3.1.1 · GroupBy · method

Assign each group a numeric identifier and return it for the corresponding rows.

Call syntax

pd.api.typing.SeriesGroupBy.ngroup(ascending=True)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
ascending Optional
Positional or keyword
Default True
bool

Choose ascending or descending order. Some sorting methods take one flag per sort key.

Returns

Series