Skip to content

Return the cumulative min computed at every element.

Description

Return the cumulative min computed at every element.

Usage

<Expr>$cum_min(..., reverse = FALSE)

Arguments

These dots are for future extensions and must be empty.
reverse If TRUE, start from the last value.

Details

The Dtypes Int8, UInt8, Int16 and UInt16 are cast to Int64 before summing to prevent overflow issues.

Value

A polars expression

Examples

library("polars")

pl$DataFrame(a = c(1:4, 2L))$with_columns(
  cum_min = pl$col("a")$cum_min(),
  cum_min_reversed = pl$col("a")$cum_min(reverse = TRUE)
)
#> shape: (5, 3)
#> ┌─────┬─────────┬──────────────────┐
#> │ a   ┆ cum_min ┆ cum_min_reversed │
#> │ --- ┆ ---     ┆ ---              │
#> │ i32 ┆ i32     ┆ i32              │
#> ╞═════╪═════════╪══════════════════╡
#> │ 1   ┆ 1       ┆ 1                │
#> │ 2   ┆ 1       ┆ 2                │
#> │ 3   ┆ 1       ┆ 2                │
#> │ 4   ┆ 1       ┆ 2                │
#> │ 2   ┆ 1       ┆ 2                │
#> └─────┴─────────┴──────────────────┘