Skip to content

Check whether each value is duplicated

Source code

Description

This is syntactic sugar for $is_unique()$not().

Usage

<Expr>$is_duplicated()

Value

Expr

Examples

library(polars)

pl$DataFrame(head(mtcars[, 1:2]))$
  with_columns(is_duplicated = pl$col("mpg")$is_duplicated())
#> shape: (6, 3)
#> ┌──────┬─────┬───────────────┐
#> │ mpg  ┆ cyl ┆ is_duplicated │
#> │ ---  ┆ --- ┆ ---           │
#> │ f64  ┆ f64 ┆ bool          │
#> ╞══════╪═════╪═══════════════╡
#> │ 21.0 ┆ 6.0 ┆ true          │
#> │ 21.0 ┆ 6.0 ┆ true          │
#> │ 22.8 ┆ 4.0 ┆ false         │
#> │ 21.4 ┆ 6.0 ┆ false         │
#> │ 18.7 ┆ 8.0 ┆ false         │
#> │ 18.1 ┆ 6.0 ┆ false         │
#> └──────┴─────┴───────────────┘