Skip to content

Get a mask of all duplicated rows in this DataFrame.

Description

Get a mask of all duplicated rows in this DataFrame.

Usage

<DataFrame>$is_duplicated()

Value

A polars Series

Examples

library("polars")

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