polars.Series.to_physical#
- Series.to_physical() Series [source]#
Cast to physical representation of the logical dtype.
List(inner)
->List(physical of inner)
Array(inner)
->Array(physical of inner)
Struct(fields)
->Struct(physical of fields)
Other data types will be left unchanged.
Warning
The physical representations are an implementation detail and not guaranteed to be stable.
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 ]