Skip to content

Get the variance.

Source code

Description

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

Usage

pl$var(..., ddof = 1)

Arguments

Characters indicating the column names, passed to pl$col(). See ?pl_col for details.
ddof An integer representing "Delta Degrees of Freedom": the divisor used in the calculation is N - ddof, where N represents the number of elements. By default ddof is 1.

Value

Expr

See Also

  • \$var()

Examples

library(polars)

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

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