Skip to content

Get unique values

Description

This method differs from $value_counts() in that it does not return the values, only the counts and might be faster.

Usage

<Expr>$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(a = c(1, 1, 2))
df$select(pl$col("a")$unique())
#> shape: (2, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 1.0 │
#> │ 2.0 │
#> └─────┘