polars.Expr.arr.unique#

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

Get the unique/distinct values in every sub-array.

engine:In MemoryStreamingDistributed
Parameters:
maintain_order

Maintain order of data. This requires more work.

Examples

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