Spec-Zone.ru › Polars

polars.Expr.meta.serialize

Expr.meta.serialize(
    file: IOBase | str | Path | None = None,
    *,
    format: SerializationFormat = 'binary',
) → bytes | str | None

Serialize this expression to a file or string in JSON format.

Parameters:
file

File path to which the result should be written. If set to None (default), the output is returned as a string instead.

format

The format in which to serialize. Options:

  • "binary": Serialize to binary format (bytes). This is the default.
  • "json": Serialize to JSON format (string).

See also

Expr.deserialize

Notes

Serialization is not stable across Polars versions: a LazyFrame serialized in one Polars version may not be deserializable in another Polars version.

Examples

Serialize the expression into a binary representation.

>>> expr = pl.col("foo").sum().over("bar")
>>> bytes = expr.meta.serialize()
>>> type(bytes)
<class 'bytes'>

The bytes can later be deserialized back into an Expr object.

>>> import io
>>> pl.Expr.deserialize(io.BytesIO(bytes))
<Expr ['col("foo").sum().over([col("ba…'] at ...>

© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.meta.serialize.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API