polars.Expr.deserialize
-
Read a serialized expression from a file.
- Parameters:
-
- source
-
Path to a file or a file-like object (by file-like object, we refer to objects that have a
read()method, such as a file handler (e.g. via builtinopenfunction) orBytesIO). - format
-
The format with which the Expr was serialized. Options:
-
"binary": Deserialize from binary format (bytes). This is the default. -
"json": Deserialize from JSON format (string).
-
Warning
This function uses
pickleif the logical plan contains Python UDFs, and as such inherits the security implications. Deserializing can execute arbitrary code, so it should only be attempted on trusted data.See also
Notes
Serialization is not stable across Polars versions: a LazyFrame serialized in one Polars version may not be deserializable in another Polars version.
Examples
>>> import io >>> expr = pl.col("foo").sum().over("bar") >>> bytes = expr.meta.serialize() >>> pl.Expr.deserialize(io.BytesIO(bytes)) <Expr ['col("foo").sum().over([col("ba…'] at ...>
classmethod Expr.deserialize(
source: str_ | Path | IOBase | bytes,
*,
format: SerializationFormat = 'binary',
) → Expr
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.deserialize.html