Get the byte value at the given index
Description
For example, index 0 would return the first byte of every
binary value and index -1 would return the last byte of
every binary value.
Usage
<Expr>$bin$get(index, ..., null_on_oob = FALSE)
Arguments
index
|
Index to return per binary value. |
…
|
These dots are for future extensions and must be empty. |
null_on_oob
|
If TRUE, return null if an index is out of
bounds. Otherwise, raise an error.
|
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(x = c("\x01\x02\x03", "", "\x04\x05"))$cast(pl$Binary)
df$with_columns(
get = pl$col("x")$bin$get(0, null_on_oob = TRUE)
)
#> shape: (3, 2)
#> ┌─────────────────┬──────┐
#> │ x ┆ get │
#> │ --- ┆ --- │
#> │ binary ┆ u8 │
#> ╞═════════════════╪══════╡
#> │ b"\x01\x02\x03" ┆ 1 │
#> │ b"" ┆ null │
#> │ b"\x04\x05" ┆ 4 │
#> └─────────────────┴──────┘