Skip to content

Get the median value.

Source code

Description

This function is syntactic sugar for pl$col(…)$median().

Usage

pl$median(...)

Arguments

Characters indicating the column names, passed to pl$col(). See ?pl_col for details.

Value

Expr

See Also

  • \$median()

Examples

library("polars")

df = pl$DataFrame(
  a = c(1, 8, 3),
  b = c(4, 5, 2),
  c = c("foo", "bar", "foo")
)

df$select(pl$median("a"))
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 3.0 │
#> └─────┘
df$select(pl$median("a", "b"))
#> shape: (1, 2)
#> ┌─────┬─────┐
#> │ a   ┆ b   │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪═════╡
#> │ 3.0 ┆ 4.0 │
#> └─────┴─────┘