Skip to content

Get the last value in a list

Source code

Description

Get the last value in a list

Usage

<Expr>$list$last()

Value

Expr

Examples

library("polars")

df = pl$DataFrame(list(a = list(3:1, NULL, 1:2)))
df$with_columns(
  last = pl$col("a")$list$last()
)
#> shape: (3, 2)
#> ┌───────────┬──────┐
#> │ a         ┆ last │
#> │ ---       ┆ ---  │
#> │ list[i32] ┆ i32  │
#> ╞═══════════╪══════╡
#> │ [3, 2, 1] ┆ 1    │
#> │ []        ┆ null │
#> │ [1, 2]    ┆ 2    │
#> └───────────┴──────┘