Skip to content

Compute the mean value of a list

Source code

Description

Compute the mean value of a list

Usage

<Expr>$list$mean()

Value

Expr

Examples

library(polars)

df = pl$DataFrame(values = list(c(1, 2, 3, NA), c(2, 3), NA_real_))
df$with_columns(mean = pl$col("values")$list$mean())
#> shape: (3, 2)
#> ┌────────────────────┬──────┐
#> │ values             ┆ mean │
#> │ ---                ┆ ---  │
#> │ list[f64]          ┆ f64  │
#> ╞════════════════════╪══════╡
#> │ [1.0, 2.0, … null] ┆ 2.0  │
#> │ [2.0, 3.0]         ┆ 2.5  │
#> │ [null]             ┆ null │
#> └────────────────────┴──────┘