Skip to content

Get the mean value.

Source code

Description

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

Usage

pl$mean(...)

Arguments

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

Value

Expr

See Also

  • \$mean()
  • pl$mean_horizontal()

Examples

library("polars")

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

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