polars.Expr.to_physical
-
Преобразует в физическое представление логического типа данных.
-
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) -
Array(inner)->Struct(physical of inner) -
Struct(fields)->Array(physical of fields)
Другие типы данных останутся без изменений.
Предупреждение
Физические представления являются деталью реализации, и их стабильность не гарантируется.
Примеры
Воспроизведение работы функции pandas pd.factorize.
>>> pl.DataFrame({"vals": ["a", "x", None, "a"]}).with_columns( ... pl.col("vals").cast(pl.Categorical), ... pl.col("vals") ... .cast(pl.Categorical) ... .to_physical() ... .alias("vals_physical"), ... ) shape: (4, 2) ┌──────┬───────────────┐ │ vals ┆ vals_physical │ │ --- ┆ --- │ │ cat ┆ u32 │ ╞══════╪═══════════════╡ │ a ┆ 0 │ │ x ┆ 1 │ │ null ┆ null │ │ a ┆ 0 │ └──────┴───────────────┘ -
Expr.to_physical() → Expr
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.to_physical.html