Skip to content

Get the maximum value.

Source code

Description

Syntactic sugar for pl$col(…)$max().

Usage

pl$max(...)

Arguments

Characters indicating the column names, passed to pl$col(). See ?pl_col for details.

Value

Expr

See Also

  • \$max()
  • pl$max_horizontal()

Examples

library("polars")

df = pl$DataFrame(
  num_1 = c(1, 8, 3),
  num_2 = c(4, 5, 2),
  chr_1 = c("foo", "bar", "foo")
)

df$select(pl$max("num_1"))
#> shape: (1, 1)
#> ┌───────┐
#> │ num_1 │
#> │ ---   │
#> │ f64   │
#> ╞═══════╡
#> │ 8.0   │
#> └───────┘
# Get the maximum value of multiple columns.
df$select(pl$max(r"(^num_\d+$)"))
#> shape: (1, 2)
#> ┌───────┬───────┐
#> │ num_1 ┆ num_2 │
#> │ ---   ┆ ---   │
#> │ f64   ┆ f64   │
#> ╞═══════╪═══════╡
#> │ 8.0   ┆ 5.0   │
#> └───────┴───────┘
df$select(pl$max("num_1", "num_2"))
#> shape: (1, 2)
#> ┌───────┬───────┐
#> │ num_1 ┆ num_2 │
#> │ ---   ┆ ---   │
#> │ f64   ┆ f64   │
#> ╞═══════╪═══════╡
#> │ 8.0   ┆ 5.0   │
#> └───────┴───────┘