Get the index of the maximal value in an array
Description
Get the index of the maximal value in an array
Usage
<Expr>$arr$arg_max()
Value
Expr
Examples
library("polars")
df = pl$DataFrame(
values = list(1:2, 2:1),
schema = list(values = pl$Array(pl$Int32, 2))
)
df$with_columns(
arg_max = pl$col("values")$arr$arg_max()
)
#> shape: (2, 2)
#> ┌───────────────┬─────────┐
#> │ values ┆ arg_max │
#> │ --- ┆ --- │
#> │ array[i32, 2] ┆ u32 │
#> ╞═══════════════╪═════════╡
#> │ [1, 2] ┆ 1 │
#> │ [2, 1] ┆ 0 │
#> └───────────────┴─────────┘