Fill null values using the specified value or strategy
Description
Fill null values using the specified value or strategy
Usage
<LazyFrame>$fill_null(
value,
strategy = NULL,
limit = NULL,
...,
matches_supertype = TRUE
)
Arguments
value
|
Value used to fill null values. |
strategy
|
Strategy used to fill null values. Must be one of:
“forward” , “backward” , “min” ,
“max” , “mean” , “zero” ,
“one” , or NULL (default).
|
limit
|
Number of consecutive null values to fill when using the
“forward” or “backward” strategy.
|
…
|
These dots are for future extensions and must be empty. |
matches_supertype
|
Fill all matching supertypes of the fill value literal.
|
Value
A polars LazyFrame
Examples
library("polars")
lf <- pl$LazyFrame(
a = c(1.5, 2, NA, 4),
b = c(1.5, NA, NA, 4)
)
lf$fill_null(99)$collect()
#> shape: (4, 2)
#> ┌──────┬──────┐
#> │ a ┆ b │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞══════╪══════╡
#> │ 1.5 ┆ 1.5 │
#> │ 2.0 ┆ 99.0 │
#> │ 99.0 ┆ 99.0 │
#> │ 4.0 ┆ 4.0 │
#> └──────┴──────┘
#> shape: (4, 2)
#> ┌─────┬─────┐
#> │ a ┆ b │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪═════╡
#> │ 1.5 ┆ 1.5 │
#> │ 2.0 ┆ 1.5 │
#> │ 2.0 ┆ 1.5 │
#> │ 4.0 ┆ 4.0 │
#> └─────┴─────┘
#> shape: (4, 2)
#> ┌─────┬─────┐
#> │ a ┆ b │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪═════╡
#> │ 1.5 ┆ 1.5 │
#> │ 2.0 ┆ 4.0 │
#> │ 4.0 ┆ 4.0 │
#> │ 4.0 ┆ 4.0 │
#> └─────┴─────┘
#> shape: (4, 2)
#> ┌─────┬─────┐
#> │ a ┆ b │
#> │ --- ┆ --- │
#> │ f64 ┆ f64 │
#> ╞═════╪═════╡
#> │ 1.5 ┆ 1.5 │
#> │ 2.0 ┆ 0.0 │
#> │ 0.0 ┆ 0.0 │
#> │ 4.0 ┆ 4.0 │
#> └─────┴─────┘