Compute the median in every sub-list
Description
Compute the median in every sub-list
Usage
<Expr>$list$median()
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(values = list(c(-1, 0, 1), c(1, 10)))
df$with_columns(
median = pl$col("values")$list$median()
)
#> shape: (2, 2)
#> ┌──────────────────┬────────┐
#> │ values ┆ median │
#> │ --- ┆ --- │
#> │ list[f64] ┆ f64 │
#> ╞══════════════════╪════════╡
#> │ [-1.0, 0.0, 1.0] ┆ 0.0 │
#> │ [1.0, 10.0] ┆ 5.5 │
#> └──────────────────┴────────┘