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",
  normalize = FALSE
)

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 column a specific name. The default is “count” if normalize = FALSE and “proportion” if normalize = TRUE.
normalize If TRUE, it gives relative frequencies of the unique values instead of their 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    │
#> └────────────────┴───────┘