polars.Expr.cat.to#

Expr.cat.to(dtype: PolarsDataType | DataTypeExpr, *, strict: bool = True) Expr[source]#

Convert to a categorical or enum dtype.

The input must be of the physical type of the categorical or enum dtype.

Parameters:
dtype

The target categorical or enum dtype.

strict

Whether to panic when encountering an illegal category.

.. warning::

This functionality is currently considered unstable. It may be changed at any point without it being considered a breaking change.