polars.Expr.list.unique#

Expr.list.unique(*, maintain_order: bool = False) Expr[source]#

Get the unique/distinct values in the list.

Parameters:
maintain_order

Maintain order of data. This requires more work.

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [[1, 1, 2]],
...     }
... )
>>> df.select(pl.col("a").list.unique())
shape: (1, 1)
┌───────────┐
│ a         │
│ ---       │
│ list[i64] │
╞═══════════╡
│ [1, 2]    │
└───────────┘