polars.Expr.meta.tree_format#

Expr.meta.tree_format(
*,
return_as_string: bool = False,
schema: None | SchemaDict = None,
) str | None[source]#

Format the expression as a tree.

Parameters:
return_as_string:

If True, return as string rather than printing to stdout.

schema

Optionally provide a schema for the expression tree formatter. This is a mapping of column names to their data types. If provided, it may be used to enhance the tree formatting with type information.

Examples

>>> e = (pl.col("foo") * pl.col("bar")).sum().over(pl.col("ham")) / 2
>>> e.meta.tree_format(return_as_string=True)