polars.apply#
- polars.apply(
- exprs: Sequence[str | Expr],
- function: Callable[[Sequence[Series]], Series | Any],
- return_dtype: PolarsDataType | None = None,
- *,
- returns_scalar: bool = True,
Apply a custom/user-defined function (UDF) in a GroupBy context.
Deprecated since version 0.19.0: This function has been renamed to
map_groups()
.- Parameters:
- exprs
Input Series to f
- function
Function to apply over the input
- return_dtype
dtype of the output Series
- returns_scalar
If the function returns a single scalar as output.
- Returns:
- Expr
Expression with the data type given by
return_dtype
.