Skip to content

Wrap column in list

Source code

Description

Aggregate values into a list.

Usage

<Expr>$implode()

Details

Use $to_struct() to wrap a DataFrame.

Value

Expr

Examples

library(polars)

df = pl$DataFrame(
  a = 1:3,
  b = 4:6
)
df$select(pl$all()$implode())
#> shape: (1, 2)
#> ┌───────────┬───────────┐
#> │ a         ┆ b         │
#> │ ---       ┆ ---       │
#> │ list[i32] ┆ list[i32] │
#> ╞═══════════╪═══════════╡
#> │ [1, 2, 3] ┆ [4, 5, 6] │
#> └───────────┴───────────┘