polars.Expr.list.arg_max#

Expr.list.arg_max() Expr[source]#

Retrieve the index of the maximum value in every sublist.

Returns:
Expr

Expression of data type UInt32 or UInt64 (depending on compilation).

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [[1, 2], [2, 1]],
...     }
... )
>>> df.with_columns(arg_max=pl.col("a").list.arg_max())
shape: (2, 2)
┌───────────┬─────────┐
│ a         ┆ arg_max │
│ ---       ┆ ---     │
│ list[i64] ┆ u32     │
╞═══════════╪═════════╡
│ [1, 2]    ┆ 1       │
│ [2, 1]    ┆ 0       │
└───────────┴─────────┘