polars.DataFrame.apply

DataFrame.apply(f: Callable[[Tuple[Any, ...]], Any], return_dtype: Optional[Type[polars.datatypes.DataType]] = None, inference_size: int = 256) polars.internals.frame.DF

Apply a custom function over the rows of the DataFrame. The rows are passed as tuple.

Beware, this is slow.

Parameters
f

Custom function/ lambda function.

return_dtype

Output type of the operation. If none given, Polars tries to infer the type.

inference_size

Only used in the case when the custom function returns rows. This uses the first n rows to determine the output schema