Skip to content

Get the maximum value horizontally across columns

Description

Get the maximum value horizontally across columns

Usage

pl$max_horizontal(...)

Arguments

\<dynamic-dots\> Columns to aggregate horizontally. Accepts expressions. Strings are parsed as column names, other non-expression inputs are parsed as literals.

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(
  a = c(1, 8, 3),
  b = c(4, 5, NA),
  c = c("x", "y", "z")
)
df$with_columns(
  max = pl$max_horizontal("a", "b")
)
#> shape: (3, 4)
#> ┌─────┬──────┬─────┬─────┐
#> │ a   ┆ b    ┆ c   ┆ max │
#> │ --- ┆ ---  ┆ --- ┆ --- │
#> │ f64 ┆ f64  ┆ str ┆ f64 │
#> ╞═════╪══════╪═════╪═════╡
#> │ 1.0 ┆ 4.0  ┆ x   ┆ 4.0 │
#> │ 8.0 ┆ 5.0  ┆ y   ┆ 8.0 │
#> │ 3.0 ┆ null ┆ z   ┆ 3.0 │
#> └─────┴──────┴─────┴─────┘