polars.min#

polars.min(column: Union[str, Sequence[polars.internals.expr.expr.Expr | str | datetime.date | datetime.datetime | int | float]]) Expr[source]#
polars.min(column: Series) int | float

Get the minimum value.

column

Column(s) to be used in aggregation. Will lead to different behavior based on the input: - Union[str, Series] -> aggregate the sum value of that column. - List[Expr] -> aggregate the min value horizontally.

Examples

>>> df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2], "c": ["foo", "bar", "foo"]})

Get the minimum value by columns with a string column name

>>> 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 the minimums for more than one column/expression use pl.col(list).min() instead:

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