polars.max#

polars.max(exprs: Series) PythonLiteral | None[source]#
polars.max(exprs: IntoExpr | Iterable[IntoExpr], *more_exprs: IntoExpr) Expr

Get the maximum value.

If a single string is passed, this is an alias for pl.col(name).max().

If a single Series is passed, this is an alias for Series.max(). This functionality is deprecated.

Otherwise, this function computes the maximum value horizontally across multiple columns. This functionality is deprecated, use pl.max_horizontal instead.

Parameters:
exprs

Column(s) to use in the aggregation. Accepts expression input. Strings are parsed as column names, other non-expression inputs are parsed as literals.

*more_exprs

Additional columns to use in the aggregation, specified as positional arguments.

See also

max_horizontal

Examples

Get the maximum value of a column by passing a single column name.

>>> 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 column-wise maximums for multiple columns by passing a regular expression, or call .max() on a multi-column expression instead.

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