Skip to content

Count the occurrences of unique values

Source code

Description

Count the occurrences of unique values

Usage

<Series>$value_counts(..., sort = TRUE, parallel = FALSE, name = "count")

Arguments

Ignored.
sort Ensure the output is sorted from most values to least.
parallel Better to turn this off in the aggregation context, as it can lead to contention.
name Give the resulting count field a specific name, defaults to “count”.

Value

DataFrame

Examples

library(polars)

as_polars_series(iris$Species, name = "flower species")$value_counts()
#> shape: (3, 2)
#> ┌────────────────┬───────┐
#> │ flower species ┆ count │
#> │ ---            ┆ ---   │
#> │ cat            ┆ u32   │
#> ╞════════════════╪═══════╡
#> │ setosa         ┆ 50    │
#> │ versicolor     ┆ 50    │
#> │ virginica      ┆ 50    │
#> └────────────────┴───────┘