Skip to content

Get the DataType wrapped in a list

Source code

Description

[Experimental] Get the DataType wrapped in a list.

Usage

<DataTypeExpr>$wrap_in_list()

Value

A polars datatype expression. This is not the same as a polars expression.

Examples

library("polars")

df <- pl$DataFrame(
  a = 1L,
  b = list("a"),
  c = data.frame(x = 1, y = 2)
)

df$select(
  a_wrapped = pl$dtype_of("a")$wrap_in_list()$display(),
  b_wrapped = pl$dtype_of("b")$wrap_in_list()$display(),
  c_wrapped = pl$dtype_of("c")$wrap_in_list()$display()
)
#> shape: (1, 3)
#> ┌───────────┬─────────────────┬─────────────────┐
#> │ a_wrapped ┆ b_wrapped       ┆ c_wrapped       │
#> │ ---       ┆ ---             ┆ ---             │
#> │ str       ┆ str             ┆ str             │
#> ╞═══════════╪═════════════════╪═════════════════╡
#> │ list[i32] ┆ list[list[str]] ┆ list[struct[2]] │
#> └───────────┴─────────────────┴─────────────────┘