_func is designed to return two columns:
from polars.type_aliases import IntoExpr, IntoExprColumnimport polars as pldef _func(x: IntoExpr): x1 = x+1 x2 = x+2 return pl.struct([x1, x2])df = pl.DataFrame({"test": np.arange(1, 11)})df.with_columns( _func(pl.col("test")).alias(["test1", "test2"]))I have tried to wrap the return values using pl.struct but it didn't work.
Expected output:
shape: (10, 3)test test1 test2i32 i32 i321 2 32 3 43 4 54 5 65 6 76 7 87 8 98 9 109 10 1110 11 12