Skip to content

Get the inner DataType of a List or Array

Source code

Description

[Experimental] Get the inner DataType of a List or Array.

Usage

<DataTypeExpr>$inner_dtype()

Value

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

Examples

library("polars")

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

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