Get whether the output DataType matches a certain selector
Description
Get whether the output DataType matches a certain selector
Usage
<DataTypeExpr>$matches(selector)
Arguments
selector
|
A selector presenting the data types to match. |
Value
A polars datatype expression. This is not the same as a polars expression.
Examples
library("polars")
df <- pl$DataFrame(a = 1:3)
df$select(
a_is_string = pl$dtype_of("a")$matches(cs$string()),
a_is_integer = pl$dtype_of("a")$matches(cs$integer()),
)
#> shape: (1, 2)
#> ┌─────────────┬──────────────┐
#> │ a_is_string ┆ a_is_integer │
#> │ --- ┆ --- │
#> │ bool ┆ bool │
#> ╞═════════════╪══════════════╡
#> │ false ┆ true │
#> └─────────────┴──────────────┘