Return the cumulative count of the non-null values in the column
Description
Return the cumulative count of the non-null values in the column
Usage
<Expr>$cum_count(..., reverse = FALSE)
Arguments
…
|
These dots are for future extensions and must be empty. |
reverse
|
If TRUE , reverse the count.
|
Value
A polars expression
Examples
library("polars")
pl$DataFrame(a = 1:4)$with_columns(
cum_count = pl$col("a")$cum_count(),
cum_count_reversed = pl$col("a")$cum_count(reverse = TRUE)
)
#> shape: (4, 3)
#> ┌─────┬───────────┬────────────────────┐
#> │ a ┆ cum_count ┆ cum_count_reversed │
#> │ --- ┆ --- ┆ --- │
#> │ i32 ┆ u32 ┆ u32 │
#> ╞═════╪═══════════╪════════════════════╡
#> │ 1 ┆ 1 ┆ 4 │
#> │ 2 ┆ 2 ┆ 3 │
#> │ 3 ┆ 3 ┆ 2 │
#> │ 4 ┆ 4 ┆ 1 │
#> └─────┴───────────┴────────────────────┘