Compress the column data using run-length encoding
Description
Run-length encoding (RLE) encodes data by storing each run of identical values as a single value and its length.
Usage
<Expr>$rle()
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(a = c(1, 1, 2, 1, NA, 1, 3, 3))
df$select(pl$col("a")$rle())$unnest("a")
#> shape: (6, 2)
#> ┌─────┬───────┐
#> │ len ┆ value │
#> │ --- ┆ --- │
#> │ u32 ┆ f64 │
#> ╞═════╪═══════╡
#> │ 2 ┆ 1.0 │
#> │ 1 ┆ 2.0 │
#> │ 1 ┆ 1.0 │
#> │ 1 ┆ null │
#> │ 1 ┆ 1.0 │
#> │ 2 ┆ 3.0 │
#> └─────┴───────┘