Skip to content

Gather every nth element

Source code

Description

Gather every nth value in the Series and return as a new Series.

Usage

<Expr>$gather_every(n, offset = 0)

Arguments

n Positive integer.
offset Starting index.

Value

Expr

Examples

library("polars")

pl$DataFrame(a = 0:24)$select(pl$col("a")$gather_every(6))
#> shape: (5, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 0   │
#> │ 6   │
#> │ 12  │
#> │ 18  │
#> │ 24  │
#> └─────┘