Skip to content

Bottom k values

Source code

Description

Return the k smallest elements. This has time complexity: O(n + k \log{}n - )

Usage

<Expr>$bottom_k(k)

Arguments

k Number of top values to get.

Value

Expr

Examples

library(polars)

pl$DataFrame(a = c(6, 1, 0, NA, Inf, NaN))$select(pl$col("a")$bottom_k(5))
#> shape: (5, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 6.0 │
#> │ 1.0 │
#> │ 0.0 │
#> │ inf │
#> │ NaN │
#> └─────┘