polars.LazyFrame.fill_nan#

LazyFrame.fill_nan(fill_value: int | float | Expr | None) LDF[source]#

Fill floating point NaN values.

Parameters:
fill_value

Value to fill the NaN values with.

Warning

Note that floating point NaN (Not a Number) are not missing values! To replace missing values, use fill_null() instead.

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [1.5, 2, float("NaN"), 4],
...         "b": [0.5, 4, float("NaN"), 13],
...     }
... ).lazy()
>>> df.fill_nan(99).collect()
shape: (4, 2)
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ f64  ┆ f64  │
╞══════╪══════╡
│ 1.5  ┆ 0.5  │
├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 2.0  ┆ 4.0  │
├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 99.0 ┆ 99.0 │
├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 4.0  ┆ 13.0 │
└──────┴──────┘