polars.Series.cat.to#

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

Create a Series with a categorical or enum dtype.

The input series must be 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.