Skip to content

Get quantile value(s)

Description

Get quantile value(s)

Usage

<Expr>$quantile(
  quantile,
  interpolation = c("nearest", "higher", "lower", "midpoint", "linear")
)

Arguments

quantile Quantile between 0.0 and 1.0.
interpolation Interpolation method. Must be one of “nearest”, “higher”, “lower”, “midpoint”, “linear”.

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(a = 0:5)
df$select(pl$col("a")$quantile(0.3))
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 2.0 │
#> └─────┘
df$select(pl$col("a")$quantile(0.3, interpolation = "higher"))
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 2.0 │
#> └─────┘
df$select(pl$col("a")$quantile(0.3, interpolation = "lower"))
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 1.0 │
#> └─────┘
df$select(pl$col("a")$quantile(0.3, interpolation = "midpoint"))
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 1.5 │
#> └─────┘
df$select(pl$col("a")$quantile(0.3, interpolation = "linear"))
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 1.5 │
#> └─────┘