polars.max#

polars.max(*names: str) Expr[source]#

Get the maximum value.

Syntactic sugar for col(names).max().

Parameters:
*names

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

See also

max_horizontal

Examples

Get the maximum value of a column.

>>> df = pl.DataFrame(
...     {
...         "a": [1, 8, 3],
...         "b": [4, 5, 2],
...         "c": ["foo", "bar", "foo"],
...     }
... )
>>> df.select(pl.max("a"))
shape: (1, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 8   │
└─────┘

Get the maximum value of multiple columns.

>>> df.select(pl.max("^a|b$"))
shape: (1, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 8   ┆ 5   │
└─────┴─────┘
>>> df.select(pl.max("a", "b"))
shape: (1, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 8   ┆ 5   │
└─────┴─────┘