Skip to content

Explode array in separate rows

Description

Returns a column with a separate row for every array element.

Usage

<Expr>$arr$explode()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(
  a = list(c(1, 2, 3), c(4, 5, 6))
)$cast(pl$Array(pl$Int64, 3))
df$select(pl$col("a")$arr$explode())
#> shape: (6, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ i64 │
#> ╞═════╡
#> │ 1   │
#> │ 2   │
#> │ 3   │
#> │ 4   │
#> │ 5   │
#> │ 6   │
#> └─────┘