Fill null values backward
Description
Fill missing values with the next to be seen values. Syntactic sugar for
$fill_null(strategy =
“backward”)
.
Usage
<Expr>$backward_fill(limit = NULL)
Arguments
limit
|
Number of consecutive null values to fill when using the
“forward” or “backward” strategy.
|
Value
Expr
Examples
library("polars")
pl$DataFrame(a = c(NA, 1, NA, 2, NA))$
with_columns(
backward = pl$col("a")$backward_fill()
)
#> shape: (5, 2)
#> ┌──────┬──────────┐
#> │ a ┆ backward │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞══════╪══════════╡
#> │ null ┆ 1.0 │
#> │ 1.0 ┆ 1.0 │
#> │ null ┆ 2.0 │
#> │ 2.0 ┆ 2.0 │
#> │ null ┆ null │
#> └──────┴──────────┘