Cast to physical representation of the logical dtype
Description
The following data types will be changed:
- 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
A polars expression
Examples
library("polars")
df <- pl$DataFrame(a = factor(c("a", "x", NA, "a")))
df$with_columns(
phys = pl$col("a")$to_physical()
)
#> shape: (4, 2)
#> ┌──────┬──────┐
#> │ a ┆ phys │
#> │ --- ┆ --- │
#> │ cat ┆ u32 │
#> ╞══════╪══════╡
#> │ a ┆ 0 │
#> │ x ┆ 1 │
#> │ null ┆ null │
#> │ a ┆ 0 │
#> └──────┴──────┘