Skip to content

Shuffle values

Source code

Description

Shuffle values

Usage

<Expr>$shuffle(seed = NULL)

Arguments

seed numeric value of 0 to 2^52 Seed for the random number generator. If NULL (default), a random seed value between 0 and 10000 is picked.

Value

Expr

Examples

library(polars)

pl$DataFrame(a = 1:4)$with_columns(shuff = pl$col("a")$shuffle(seed = 1))
#> shape: (4, 2)
#> ┌─────┬───────┐
#> │ a   ┆ shuff │
#> │ --- ┆ ---   │
#> │ i32 ┆ i32   │
#> ╞═════╪═══════╡
#> │ 1   ┆ 2     │
#> │ 2   ┆ 3     │
#> │ 3   ┆ 4     │
#> │ 4   ┆ 1     │
#> └─────┴───────┘