Skip to content

Index of max value

Source code

Description

Get the index of the maximal value.

Usage

<Expr>$arg_max()

Value

Expr

Examples

library("polars")

pl$DataFrame(
  a = c(6, 1, 0, NA, Inf, NaN)
)$with_columns(arg_max = pl$col("a")$arg_max())
#> shape: (6, 2)
#> ┌──────┬─────────┐
#> │ a    ┆ arg_max │
#> │ ---  ┆ ---     │
#> │ f64  ┆ u32     │
#> ╞══════╪═════════╡
#> │ 6.0  ┆ 4       │
#> │ 1.0  ┆ 4       │
#> │ 0.0  ┆ 4       │
#> │ null ┆ 4       │
#> │ inf  ┆ 4       │
#> │ NaN  ┆ 4       │
#> └──────┴─────────┘