Drop duplicate rows
Description
Drop duplicate rows
Usage
<DataFrame>$unique(
...,
keep = c("any", "none", "first", "last"),
maintain_order = FALSE,
subset = deprecated()
)
Arguments
Value
A polars DataFrame
Examples
library("polars")
df <- pl$DataFrame(
foo = c(1, 2, 3, 1),
bar = c("a", "a", "a", "a"),
ham = c("b", "b", "b", "b"),
)
df$unique(maintain_order = TRUE)
#> shape: (3, 3)
#> ┌─────┬─────┬─────┐
#> │ foo ┆ bar ┆ ham │
#> │ --- ┆ --- ┆ --- │
#> │ f64 ┆ str ┆ str │
#> ╞═════╪═════╪═════╡
#> │ 1.0 ┆ a ┆ b │
#> │ 2.0 ┆ a ┆ b │
#> │ 3.0 ┆ a ┆ b │
#> └─────┴─────┴─────┘
#> shape: (1, 3)
#> ┌─────┬─────┬─────┐
#> │ foo ┆ bar ┆ ham │
#> │ --- ┆ --- ┆ --- │
#> │ f64 ┆ str ┆ str │
#> ╞═════╪═════╪═════╡
#> │ 1.0 ┆ a ┆ b │
#> └─────┴─────┴─────┘
#> shape: (3, 3)
#> ┌─────┬─────┬─────┐
#> │ foo ┆ bar ┆ ham │
#> │ --- ┆ --- ┆ --- │
#> │ f64 ┆ str ┆ str │
#> ╞═════╪═════╪═════╡
#> │ 2.0 ┆ a ┆ b │
#> │ 3.0 ┆ a ┆ b │
#> │ 1.0 ┆ a ┆ b │
#> └─────┴─────┴─────┘