polars.Series.to_physical#
- Series.to_physical() Series[source]#
Cast to physical representation of the logical dtype.
polars.datatypes.Date()->polars.datatypes.Int32()polars.datatypes.Datetime()->polars.datatypes.Int64()polars.datatypes.Time()->polars.datatypes.Int64()polars.datatypes.Duration()->polars.datatypes.Int64()polars.datatypes.Categorical()->polars.datatypes.UInt32()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 ]