pandas.api.typing.DataFrameGroupBy.apply

pandas 3.1.1 · GroupBy · method

Call a function with each group DataFrame and assemble the results. The callable can return a scalar, Series or DataFrame.

Call syntax

pd.api.typing.DataFrameGroupBy.apply(func, *args, include_groups=False, **kwargs)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
func Required
Positional or keyword
callable

Supply a supported operation name or a callable, depending on this API.

*args Optional
Additional positional arguments
include_groups Optional
Keyword only
Default False
bool

Choose whether the grouping columns are included in inputs passed to the callback.

**kwargs Optional
Additional keyword arguments

Returns

Series or DataFrame