Fill null values using interpolation
Description
Fill null values using interpolation
Usage
<Expr>$interpolate(method = c("linear", "nearest"))
Arguments
method
|
Interpolation method. Must be one of “linear” or
“nearest” .
|
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(a = c(1, NA, 3), b = c(1, NaN, 3))
df$with_columns(
a_interpolated = pl$col("a")$interpolate(),
b_interpolated = pl$col("b")$interpolate()
)
#> shape: (3, 4)
#> ┌──────┬─────┬────────────────┬────────────────┐
#> │ a ┆ b ┆ a_interpolated ┆ b_interpolated │
#> │ --- ┆ --- ┆ --- ┆ --- │
#> │ f64 ┆ f64 ┆ f64 ┆ f64 │
#> ╞══════╪═════╪════════════════╪════════════════╡
#> │ 1.0 ┆ 1.0 ┆ 1.0 ┆ 1.0 │
#> │ null ┆ NaN ┆ 2.0 ┆ NaN │
#> │ 3.0 ┆ 3.0 ┆ 3.0 ┆ 3.0 │
#> └──────┴─────┴────────────────┴────────────────┘