Skip to content

Returns a column with a separate row for every list element

Source code

Description

Returns a column with a separate row for every list element

Usage

<Expr>$list$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)))
df$select(pl$col("a")$list$explode())
#> shape: (6, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 1.0 │
#> │ 2.0 │
#> │ 3.0 │
#> │ 4.0 │
#> │ 5.0 │
#> │ 6.0 │
#> └─────┘