polars.Expr.forward_fill#
- Expr.forward_fill(limit: int | None = None) Expr [source]#
Fill missing values with the last non-null value.
- Parameters:
- limit
The number of consecutive null values to forward fill.
See also
Examples
>>> df = pl.DataFrame( ... { ... "a": [1, 2, None], ... "b": [4, None, 6], ... } ... ) >>> df.select(pl.all().forward_fill()) shape: (3, 2) ┌─────┬─────┐ │ a ┆ b │ │ --- ┆ --- │ │ i64 ┆ i64 │ ╞═════╪═════╡ │ 1 ┆ 4 │ │ 2 ┆ 4 │ │ 2 ┆ 6 │ └─────┴─────┘