pandas.api.typing.SeriesGroupBy.first

pandas 3.1.1 · GroupBy · method

Take the first value in each group or time bin, skipping missing values by default where supported.

Call syntax

pd.api.typing.SeriesGroupBy.first(numeric_only=False, min_count=-1, skipna=True)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
numeric_only Optional
Positional or keyword
Default False
bool

Restrict the calculation to columns pandas considers numeric where applicable.

min_count Optional
Positional or keyword
Default -1
int

Require at least this many valid values before producing a nonmissing result.

skipna Optional
Positional or keyword
Default True
bool

Choose whether to exclude missing values during the calculation.

Returns

Series or DataFrame