polars.lazyframe.group_by.LazyGroupBy.apply#

LazyGroupBy.apply(
function: Callable[[DataFrame], DataFrame],
schema: SchemaDict | None,
) LazyFrame[source]#

Apply a custom/user-defined function (UDF) over the groups as a new DataFrame.

Deprecated since version 0.19.0: This method has been renamed to LazyGroupBy.map_groups().

Parameters:
function

Function to apply over each group of the LazyFrame.

schema

Schema of the output function. This has to be known statically. If the given schema is incorrect, this is a bug in the caller’s query and may lead to errors. If set to None, polars assumes the schema is unchanged.