Cumulative minimum
Description
Get an array with the cumulative min computed at every element.
Usage
<Expr>$cum_min(reverse = FALSE)
Arguments
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
Expr
Examples
library("polars")
pl$DataFrame(a = c(1:4, 2L))$with_columns(
pl$col("a")$cum_min()$alias("cum_min"),
pl$col("a")$cum_min(reverse = TRUE)$alias("cum_min_reversed")
)
#> 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 │
#> └─────┴─────────┴──────────────────┘