Skip to content

Get a mask of all unique rows in this DataFrame.

Description

Get a mask of all unique rows in this DataFrame.

Usage

<DataFrame>$is_unique()

Value

A polars Series

Examples

library("polars")

df <- pl$DataFrame(
  a = c(1, 2, 3, 1),
  b = c("x", "y", "z", "x")
)
df$is_unique()
#> shape: (4,)
#> Series: '' [bool]
#> [
#>  false
#>  true
#>  true
#>  false
#> ]
# This mask can be used to visualize the unique lines like this:
df$filter(df$is_unique())
#> shape: (2, 2)
#> ┌─────┬─────┐
#> │ a   ┆ b   │
#> │ --- ┆ --- │
#> │ f64 ┆ str │
#> ╞═════╪═════╡
#> │ 2.0 ┆ y   │
#> │ 3.0 ┆ z   │
#> └─────┴─────┘