Skip to content

Cast an Expr to its physical representation

Source code

Description

The following DataTypes will be converted:

  • Date -\> Int32
  • Datetime -\> Int64
  • Time -\> Int64
  • Duration -\> Int64
  • Categorical -\> UInt32
  • List(inner) -\> List(physical of inner) Other data types will be left unchanged.

Usage

<Expr>$to_physical()

Value

Expr

Examples

library("polars")

pl$DataFrame(
  list(vals = c("a", "x", NA, "a", "b"))
)$with_columns(
  pl$col("vals")$cast(pl$Categorical()),
  pl$col("vals")
  $cast(pl$Categorical())
  $to_physical()
  $alias("vals_physical")
)
#> shape: (5, 2)
#> ┌──────┬───────────────┐
#> │ vals ┆ vals_physical │
#> │ ---  ┆ ---           │
#> │ cat  ┆ u32           │
#> ╞══════╪═══════════════╡
#> │ a    ┆ 0             │
#> │ x    ┆ 1             │
#> │ null ┆ null          │
#> │ a    ┆ 0             │
#> │ b    ┆ 2             │
#> └──────┴───────────────┘