Get the categories stored in this data type
Description
$cat$get_categories() is
deprecated. To get the distinct values present in a Categorical column,
use $unique(). For the fixed
category list of an Enum, use its dtype$categories.
Usage
<Expr>$cat$get_categories()
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(
cats = factor(c("z", "z", "k", "a", "b")),
vals = factor(c(3, 1, 2, 2, 3))
)
df
#> shape: (5, 2)
#> ┌──────┬──────┐
#> │ cats ┆ vals │
#> │ --- ┆ --- │
#> │ cat ┆ cat │
#> ╞══════╪══════╡
#> │ z ┆ 3 │
#> │ z ┆ 1 │
#> │ k ┆ 2 │
#> │ a ┆ 2 │
#> │ b ┆ 3 │
#> └──────┴──────┘
#> shape: (7, 1)
#> ┌──────┐
#> │ cats │
#> │ --- │
#> │ str │
#> ╞══════╡
#> │ z │
#> │ k │
#> │ a │
#> │ b │
#> │ 3 │
#> │ 1 │
#> │ 2 │
#> └──────┘
#> shape: (7, 1)
#> ┌──────┐
#> │ vals │
#> │ --- │
#> │ str │
#> ╞══════╡
#> │ z │
#> │ k │
#> │ a │
#> │ b │
#> │ 3 │
#> │ 1 │
#> │ 2 │
#> └──────┘