Skip to content

Count unique values

Source code

Description

Return a count of the unique values in the order of appearance. This method differs from $value_counts() in that it does not return the values, only the counts and it might be faster.

Usage

<Expr>$unique_counts()

Value

Expr

Examples

library(polars)

pl$DataFrame(iris)$select(pl$col("Species")$unique_counts())
#> shape: (3, 1)
#> ┌─────────┐
#> │ Species │
#> │ ---     │
#> │ u32     │
#> ╞═════════╡
#> │ 50      │
#> │ 50      │
#> │ 50      │
#> └─────────┘