Skip to content

Fill floating point NaN value with a fill value

Source code

Description

Fill floating point NaN value with a fill value

Usage

<Expr>$fill_nan(value = NULL)

Arguments

value Value used to fill NaN values.

Value

Expr

Examples

library("polars")

pl$DataFrame(a = c(NaN, 1, NaN, 2, NA))$
  with_columns(
  literal = pl$col("a")$fill_nan(999),
  # implicit coercion to string
  string = pl$col("a")$fill_nan("invalid")
)
#> shape: (5, 3)
#> ┌──────┬─────────┬─────────┐
#> │ a    ┆ literal ┆ string  │
#> │ ---  ┆ ---     ┆ ---     │
#> │ f64  ┆ f64     ┆ str     │
#> ╞══════╪═════════╪═════════╡
#> │ NaN  ┆ 999.0   ┆ invalid │
#> │ 1.0  ┆ 1.0     ┆ 1.0     │
#> │ NaN  ┆ 999.0   ┆ invalid │
#> │ 2.0  ┆ 2.0     ┆ 2.0     │
#> │ null ┆ null    ┆ null    │
#> └──────┴─────────┴─────────┘