polars.min#

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

Get the minimum value.

If a single column is passed, get the minimum value of that column (vertical). If multiple columns are passed, get the minimum value of each row (horizontal).

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.

Examples

Get the minimum value by columns with a string column name.

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

Get the minimum value by row with a list of columns/expressions.

>>> df.select(pl.min(["a", "b"]))
shape: (3, 1)
┌─────┐
│ min │
│ --- │
│ i64 │
╞═════╡
│ 1   │
│ 5   │
│ 2   │
└─────┘

To aggregate minimums for more than one column/expression use pl.col(list).min() or a regular expression selector like pl.sum(regex):

>>> df.select(pl.col(["a", "b"]).min())
shape: (1, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 1   ┆ 2   │
└─────┴─────┘
>>> df.select(pl.min("^.*[ab]$"))
shape: (1, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 1   ┆ 2   │
└─────┴─────┘