Select all categorical columns
Description
Select all categorical columns
Usage
cs__categorical()
Value
A Polars selector
See Also
cs for the documentation on operators supported by Polars selectors.
Examples
library("polars")
df <- pl$DataFrame(
foo = c("xx", "yy"),
bar = c(123, 456),
baz = c(2.0, 5.5),
.schema_overrides = list(foo = pl$Categorical()),
)
# Select categorical columns:
df$select(cs$categorical())
#> shape: (2, 1)
#> ┌─────┐
#> │ foo │
#> │ --- │
#> │ cat │
#> ╞═════╡
#> │ xx │
#> │ yy │
#> └─────┘
#> shape: (2, 2)
#> ┌───────┬─────┐
#> │ bar ┆ baz │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═══════╪═════╡
#> │ 123.0 ┆ 2.0 │
#> │ 456.0 ┆ 5.5 │
#> └───────┴─────┘