Get the unique values in every sub-array
Description
Get the unique values in every sub-array
Usage
<Expr>$arr$unique(..., maintain_order = FALSE)
Arguments
…
|
These dots are for future extensions and must be empty. |
maintain_order
|
Maintain order of data. This requires more work. |
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(
values = list(c(1, 1, 2), c(4, 4, 4), c(NA, 6, 7)),
)$cast(pl$Array(pl$Float64, 3))
df$with_columns(unique = pl$col("values")$arr$unique())
#> shape: (3, 2)
#> ┌──────────────────┬──────────────────┐
#> │ values ┆ unique │
#> │ --- ┆ --- │
#> │ array[f64, 3] ┆ list[f64] │
#> ╞══════════════════╪══════════════════╡
#> │ [1.0, 1.0, 2.0] ┆ [1.0, 2.0] │
#> │ [4.0, 4.0, 4.0] ┆ [4.0] │
#> │ [null, 6.0, 7.0] ┆ [null, 6.0, 7.0] │
#> └──────────────────┴──────────────────┘