polars.Expr.approx_n_unique#
- Expr.approx_n_unique() Self [source]#
Approximate count of unique values.
This is done using the HyperLogLog++ algorithm for cardinality estimation.
Examples
>>> df = pl.DataFrame({"a": [1, 1, 2]}) >>> df.select(pl.col("a").approx_n_unique()) shape: (1, 1) ┌─────┐ │ a │ │ --- │ │ u32 │ ╞═════╡ │ 2 │ └─────┘