Skip to content

Compute the variance in every sub-list

Description

Compute the variance in every sub-list

Usage

<Expr>$list$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 expression

Examples

library("polars")

df <- pl$DataFrame(values = list(c(-1, 0, 1), c(1, 10)))

df$with_columns(
  var = pl$col("values")$list$var()
)
#> shape: (2, 2)
#> ┌──────────────────┬──────┐
#> │ values           ┆ var  │
#> │ ---              ┆ ---  │
#> │ list[f64]        ┆ f64  │
#> ╞══════════════════╪══════╡
#> │ [-1.0, 0.0, 1.0] ┆ 1.0  │
#> │ [1.0, 10.0]      ┆ 40.5 │
#> └──────────────────┴──────┘