ast_repr

pydiverse.transform.ast_repr(
verb_depth: int = 7,
expr_depth: int = 2,
pipe: bool = False,
) Pipeable | None[source]

Prints the AST of the table to stdout.

Parameters:

pipe – If set to True, the table is returned, else None is returned.

Note

During interactive development in the python shell, you usually want to keep pipe = False, else the table is printed, too. The main use for pipe = True is when you don’t want to break a long sequence of verbs in a file.

Examples

>>> tbl1 = Table(dict(a=[1, 2], b=["x", "y"]), name="tbl1")
>>> tbl2 = Table(dict(a=[1, 2], c=["z", "zz"]), name="tbl2")
>>> (
...     tbl1
...     >> mutate(u=C.a + 5)
...     >> select(tbl1.a)
...     >> left_join(
...         tbl2
...         >> arrange(tbl2.a)
...         >> filter(tbl2.c.str.len() <= 10)
...         >> full_join(s := tbl2 >> alias("s"), on="c"),
...         on="a",
...     )
...     >> slice_head(32)
...     >> ast_repr()
... )
tbl2 = Table(df, Polars(), name="tbl2")
tbl1 = Table(df, Polars(), name="tbl1")
(

tbl1 >> mutate(u=tbl1.a + 5) >> select(tbl1.a) >> join(

tbl2 >> arrange(tbl2.a) >> filter(tbl2.c.str.len() <= 10) >> join(

tbl2 >> alias(“s”) >> rename({“a”: “a_s”, “c”: “c_s”}), how=”full”, on=tbl2.c == s.c, validate=”m:m”,

) >> rename({“a”: “a_tbl2”}), how=”left”, on=tbl1.a == tbl2.a, validate=”m:m”,

) >> slice_head(n=32, offset=0)

)