Skip to content

Convert an Array column into a List column with the same inner data type

Description

Convert an Array column into a List column with the same inner data type

Usage

<Expr>$arr$to_list()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(
  a = list(c(1, 2), c(3, 4))
)$cast(pl$Array(pl$Int8, 2))

df$with_columns(
  list = pl$col("a")$arr$to_list()
)
#> shape: (2, 2)
#> ┌──────────────┬──────────┐
#> │ a            ┆ list     │
#> │ ---          ┆ ---      │
#> │ array[i8, 2] ┆ list[i8] │
#> ╞══════════════╪══════════╡
#> │ [1, 2]       ┆ [1, 2]   │
#> │ [3, 4]       ┆ [3, 4]   │
#> └──────────────┴──────────┘