Reinterpret the underlying bits of a same-size numeric type.
Description
Reinterpret the underlying bits of a same-size numeric type.
Usage
<Expr>$reinterpret(..., signed = NULL, dtype = NULL)
Arguments
…
|
These dots are for future extensions and must be empty. |
signed
|
Whether to reinterpret as a signed or unsigned integer of the same width
as the input. Must specify exactly one of signed and
dtype.
|
dtype
|
Target data type for the reinterpretation. Must specify exactly one of
signed and dtype.
|
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(a = c(1, 1, 2))$cast(pl$UInt64)
# Reinterpret column a as Int64
df$with_columns(
reinterpreted = pl$col("a")$reinterpret(dtype = pl$Int64)
)
#> shape: (3, 2)
#> ┌─────┬───────────────┐
#> │ a ┆ reinterpreted │
#> │ --- ┆ --- │
#> │ u64 ┆ i64 │
#> ╞═════╪═══════════════╡
#> │ 1 ┆ 1 │
#> │ 1 ┆ 1 │
#> │ 2 ┆ 2 │
#> └─────┴───────────────┘