Skip to content

Approx count unique values

Source code

Description

This is done using the HyperLogLog++ algorithm for cardinality estimation.

Usage

<Expr>$approx_n_unique()

Value

Expr

Examples

library("polars")

as_polars_df(mtcars)$select(count = pl$col("cyl")$approx_n_unique())
#> shape: (1, 1)
#> ┌───────┐
#> │ count │
#> │ ---   │
#> │ u32   │
#> ╞═══════╡
#> │ 3     │
#> └───────┘