Skip to content

Get the maximum value

Description

This function is syntactic sugar for col(names)$max().

Usage

pl$max(...)

Arguments

Name(s) of the columns to use in the aggregation.

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(
  a = c(1, 8, 3),
  b = c(4, 5, 2),
  c = c("foo", "bar", "foo")
)

# Get the maximum value of a column
df$select(pl$max("a"))
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 8.0 │
#> └─────┘
# Get the maximum value of multiple columns
df$select(pl$max("a", "b"))
#> shape: (1, 2)
#> ┌─────┬─────┐
#> │ a   ┆ b   │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪═════╡
#> │ 8.0 ┆ 5.0 │
#> └─────┴─────┘