polars.LazyFrame.pipe¶
- LazyFrame.pipe(func: Callable[[...], Any], *args: Any, **kwargs: Any) Any ¶
Apply a function on Self.
- Parameters
- func
Callable.
- args
Arguments.
- kwargs
Keyword arguments.
Examples
>>> def cast_str_to_int(data, col_name): ... return data.with_column(pl.col(col_name).cast(pl.Int64)) ... >>> df = pl.DataFrame({"a": [1, 2, 3, 4], "b": ["10", "20", "30", "40"]}).lazy() >>> df.pipe(cast_str_to_int, col_name="b").collect() shape: (4, 2) ┌─────┬─────┐ │ a ┆ b │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞═════╪═════╡ │ 1 ┆ 10 │ ├╌╌╌╌╌┼╌╌╌╌╌┤ │ 2 ┆ 20 │ ├╌╌╌╌╌┼╌╌╌╌╌┤ │ 3 ┆ 30 │ ├╌╌╌╌╌┼╌╌╌╌╌┤ │ 4 ┆ 40 │ └─────┴─────┘