Skip to content

Reverse values in a list

Source code

Description

Reverse values in a list

Usage

<Expr>$list$reverse()

Value

Expr

Examples

library("polars")

df = pl$DataFrame(values = list(c(1, 2, 3, NA), c(2, 3), NA_real_))
df$with_columns(reverse = pl$col("values")$list$reverse())
#> shape: (3, 2)
#> ┌────────────────────┬────────────────────┐
#> │ values             ┆ reverse            │
#> │ ---                ┆ ---                │
#> │ list[f64]          ┆ list[f64]          │
#> ╞════════════════════╪════════════════════╡
#> │ [1.0, 2.0, … null] ┆ [null, 3.0, … 1.0] │
#> │ [2.0, 3.0]         ┆ [3.0, 2.0]         │
#> │ [null]             ┆ [null]             │
#> └────────────────────┴────────────────────┘