polars.Series.to_physical#
- Series.to_physical() Series [source]#
Cast to physical representation of the logical dtype.
List(inner)
->List(physical of inner)
Other data types will be left unchanged.
Examples
Replicating the pandas pd.Series.factorize method.
>>> s = pl.Series("values", ["a", None, "x", "a"]) >>> s.cast(pl.Categorical).to_physical() shape: (4,) Series: 'values' [u32] [ 0 null 1 0 ]