Expand the struct into its individual fields
Description
This is an alias for Expr$struct$field("*")
.
Usage
<Expr>$struct$unnest()
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(
aaa = c(1, 2),
bbb = c("ab", "cd"),
ccc = c(TRUE, NA),
ddd = list(1:2, 3)
)$select(struct_col = pl$struct("aaa", "bbb", "ccc", "ddd"))
df
#> shape: (2, 1)
#> ┌────────────────────────────┐
#> │ struct_col │
#> │ --- │
#> │ struct[4] │
#> ╞════════════════════════════╡
#> │ {1.0,"ab",true,[1.0, 2.0]} │
#> │ {2.0,"cd",null,[3.0]} │
#> └────────────────────────────┘
#> shape: (2, 4)
#> ┌─────┬─────┬──────┬────────────┐
#> │ aaa ┆ bbb ┆ ccc ┆ ddd │
#> │ --- ┆ --- ┆ --- ┆ --- │
#> │ f64 ┆ str ┆ bool ┆ list[f64] │
#> ╞═════╪═════╪══════╪════════════╡
#> │ 1.0 ┆ ab ┆ true ┆ [1.0, 2.0] │
#> │ 2.0 ┆ cd ┆ null ┆ [3.0] │
#> └─────┴─────┴──────┴────────────┘