Skip to content

Get unique values in a list

Source code

Description

Get unique values in a list

Usage

<Expr>$list$unique(maintain_order = FALSE)

Arguments

maintain_order Maintain order of data. This requires more work.

Value

Expr

Examples

library("polars")

df = pl$DataFrame(values = list(c(2, 2, NA), c(1, 2, 3), NA_real_))
df$with_columns(unique = pl$col("values")$list$unique())
#> shape: (3, 2)
#> ┌──────────────────┬─────────────────┐
#> │ values           ┆ unique          │
#> │ ---              ┆ ---             │
#> │ list[f64]        ┆ list[f64]       │
#> ╞══════════════════╪═════════════════╡
#> │ [2.0, 2.0, null] ┆ [null, 2.0]     │
#> │ [1.0, 2.0, 3.0]  ┆ [1.0, 2.0, 3.0] │
#> │ [null]           ┆ [null]          │
#> └──────────────────┴─────────────────┘