polars.Expr.deserialize#

classmethod Expr.deserialize(source: str | Path | IOBase) Self[source]#

Read an expression from a JSON 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 builtin open function) or BytesIO).

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.

Examples

>>> from io import StringIO
>>> expr = pl.col("foo").sum().over("bar")
>>> json = expr.meta.serialize()
>>> pl.Expr.deserialize(StringIO(json))  
<Expr ['col("foo").sum().over([col("ba…'] at ...>