Skip to content

Gather values by index

Source code

Description

Gather values by index

Usage

<Expr>$gather(indices)

Arguments

indices R vector or Series, or Expr that leads to a Series of dtype Int64. (0-indexed)

Value

Expr

Examples

library("polars")

df = pl$DataFrame(a = 1:10)

df$select(pl$col("a")$gather(c(0, 2, 4, -1)))
#> shape: (4, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 1   │
#> │ 3   │
#> │ 5   │
#> │ 10  │
#> └─────┘