polars.LazyFrame.serialize
-
Serialize the logical plan of this LazyFrame 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) (deprecated).
-
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
Serialize the logical plan into a binary representation.
>>> lf = pl.LazyFrame({"a": [1, 2, 3]}).sum() >>> bytes = lf.serialize()The bytes can later be deserialized back into a LazyFrame.
>>> import io >>> pl.LazyFrame.deserialize(io.BytesIO(bytes)).collect() shape: (1, 1) ┌─────┐ │ a │ │ --- │ │ i64 │ ╞═════╡ │ 6 │ └─────┘
LazyFrame.serialize(
file: IOBase | str | Path | None = None,
*,
format: SerializationFormat = 'binary',
) → bytes | str | None
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/lazyframe/api/polars.LazyFrame.serialize.html