polars.lazyframe.group_by.LazyGroupBy.quantile#
- LazyGroupBy.quantile(
- quantile: float,
- interpolation: RollingInterpolationMethod = 'nearest',
Compute the quantile per group.
- Parameters:
- quantile
Quantile between 0.0 and 1.0.
- interpolation{‘nearest’, ‘higher’, ‘lower’, ‘midpoint’, ‘linear’}
Interpolation method.
Examples
>>> ldf = pl.DataFrame( ... { ... "a": [1, 2, 2, 3, 4, 5], ... "b": [0.5, 0.5, 4, 10, 13, 14], ... "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"], ... } ... ).lazy() >>> ldf.group_by("d", maintain_order=True).quantile(1).collect() shape: (3, 3) ┌────────┬─────┬──────┐ │ d ┆ a ┆ b │ │ --- ┆ --- ┆ --- │ │ str ┆ f64 ┆ f64 │ ╞════════╪═════╪══════╡ │ Apple ┆ 3.0 ┆ 10.0 │ │ Orange ┆ 2.0 ┆ 0.5 │ │ Banana ┆ 5.0 ┆ 14.0 │ └────────┴─────┴──────┘