Skip to content

Compute the most occurring value(s)

Description

Compute the most occurring value(s)

Usage

<Expr>$mode()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(a = c(1, 1, 2, 3), b = c(1, 1, 2, 2))
df$select(pl$col("a")$mode())
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 1.0 │
#> └─────┘
df$select(pl$col("b")$mode())
#> shape: (2, 1)
#> ┌─────┐
#> │ b   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 1.0 │
#> │ 2.0 │
#> └─────┘