polars_lazy::dsl

Function map_multiple

pub fn map_multiple<F, E>(
    function: F,
    expr: E,
    output_type: SpecialEq<Arc<dyn FunctionOutputField>>,
) -> Expr
where F: Fn(&mut [Column]) -> Result<Option<Column>, PolarsError> + 'static + Send + Sync, E: AsRef<[Expr]>,
Expand description

Apply a function/closure over multiple columns once the logical plan get executed.

This function is very similar to apply_multiple, but differs in how it handles aggregations.

  • map_multiple should be used for operations that are independent of groups, e.g. multiply * 2, or raise to the power
  • apply_multiple should be used for operations that work on a group of data. e.g. sum, count, etc.

It is the responsibility of the caller that the schema is correct by giving the correct output_type. If None given the output type of the input expr is used.