polars.Expr.arg_max#

Expr.arg_max() → Expr[source]#

Get an index of a maximal value.

Null values are ignored, and so are NaN values of a float column. Values of a nested dtype (List, Array, Struct and Map) compare in the order sort() puts them in, where NaN is larger than any other number.

When multiple values are equal to the maximum, this function may arbitrarily return the index of any of the maximum values. In this case, the returned index is not guaranteed to be the same across multiple runs.

engine:In MemoryStreamingDistributed

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [20, 10, 30],
...     }
... )
>>> df.select(pl.col("a").arg_max())
shape: (1, 1)
┌─────┐
│ a   │
│ --- │
│ u32 │
╞═════╡
│ 2   │
└─────┘