Skip to content

Aggregate the columns in the DataFrame to their variance value

Description

Aggregate the columns in the DataFrame to their variance value

Usage

<DataFrame>$var(ddof = 1)

Arguments

ddof "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

A polars DataFrame

Examples

library("polars")

df <- pl$DataFrame(a = 1:4, b = c(1, 2, 1, 1))
df$var()
#> shape: (1, 2)
#> ┌──────────┬──────┐
#> │ a        ┆ b    │
#> │ ---      ┆ ---  │
#> │ f64      ┆ f64  │
#> ╞══════════╪══════╡
#> │ 1.666667 ┆ 0.25 │
#> └──────────┴──────┘
df$var(ddof = 0)
#> shape: (1, 2)
#> ┌──────┬────────┐
#> │ a    ┆ b      │
#> │ ---  ┆ ---    │
#> │ f64  ┆ f64    │
#> ╞══════╪════════╡
#> │ 1.25 ┆ 0.1875 │
#> └──────┴────────┘