polars.LazyFrame.deserialize#
- classmethod LazyFrame.deserialize(source: str | Path | IOBase) Self [source]#
Read a logical plan from a JSON file to construct a LazyFrame.
- 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 builtinopen
function) orBytesIO
).
Warning
This function uses
pickle
under some circumstances, and as such inherits the security implications. Deserializing can execute arbitrary code so it should only be attempted on trusted data. pickle is only used when the logical plan contains python UDFs.See also
Examples
>>> import io >>> lf = pl.LazyFrame({"a": [1, 2, 3]}).sum() >>> json = lf.serialize() >>> pl.LazyFrame.deserialize(io.StringIO(json)).collect() shape: (1, 1) ┌─────┐ │ a │ │ --- │ │ i64 │ ╞═════╡ │ 6 │ └─────┘