Explode array in separate rows
Description
Returns a column with a separate row for every array element.
Usage
<Expr>$arr$explode(..., empty_as_null = TRUE, keep_nulls = TRUE)
Arguments
…
|
These dots are for future extensions and must be empty. |
empty_as_null
|
Indicates to explode an empty list/array into a null.
|
keep_nulls
|
Indicates to explode a null list/array into a
null.
|
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 │
#> └─────┘