Skip to content

Return a single value by index

Description

Return a single value by index

Usage

<Expr>$get(index)

Arguments

index An expression that leads to a UInt32 dtyped Series.

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(
  group = c("one", "one", "one", "two", "two", "two"),
  value = c(1, 98, 2, 3, 99, 4)
)
df$group_by("group", maintain_order = TRUE)$agg(
  pl$col("value")$get(1)
)
#> shape: (2, 3)
#> ┌───────┬────────────────┬───────┐
#> │ group ┆ maintain_order ┆ value │
#> │ ---   ┆ ---            ┆ ---   │
#> │ str   ┆ bool           ┆ f64   │
#> ╞═══════╪════════════════╪═══════╡
#> │ one   ┆ true           ┆ 98.0  │
#> │ two   ┆ true           ┆ 99.0  │
#> └───────┴────────────────┴───────┘