Skip to content

Drop duplicated rows

Description

Drop duplicated rows

Usage

## S3 method for class 'RPolarsDataFrame'
unique(x, incomparables = FALSE, subset = NULL, keep = "first", ...)

# S3 method for class 'RPolarsLazyFrame'
unique(x, incomparables = FALSE, subset = NULL, keep = "first", ...)

Arguments

x A DataFrame or LazyFrame
incomparables Not used.
subset Character vector of column names to drop duplicated values from.
keep Either “first”, “last”, or “none”.
Not used.

Examples

library(polars)

df = pl$DataFrame(
  x = as.numeric(c(1, 1:5)),
  y = as.numeric(c(1, 1:5)),
  z = as.numeric(c(1, 1, 1:4))
)
unique(df)
#> shape: (5, 3)
#> ┌─────┬─────┬─────┐
#> │ x   ┆ y   ┆ z   │
#> │ --- ┆ --- ┆ --- │
#> │ f64 ┆ f64 ┆ f64 │
#> ╞═════╪═════╪═════╡
#> │ 5.0 ┆ 5.0 ┆ 4.0 │
#> │ 1.0 ┆ 1.0 ┆ 1.0 │
#> │ 4.0 ┆ 4.0 ┆ 3.0 │
#> │ 2.0 ┆ 2.0 ┆ 1.0 │
#> │ 3.0 ┆ 3.0 ┆ 2.0 │
#> └─────┴─────┴─────┘