polars.Expr.fill_nan#

Expr.fill_nan(fill_value: str | int | float | bool | polars.internals.expr.expr.Expr | None) Expr[source]#

Fill floating point NaN value with a fill value.

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [1.0, None, float("nan")],
...         "b": [4.0, float("nan"), 6],
...     }
... )
>>> df.fill_nan("zero")
shape: (3, 2)
┌──────┬──────┐
│ a    ┆ b    │
│ ---  ┆ ---  │
│ str  ┆ str  │
╞══════╪══════╡
│ 1.0  ┆ 4.0  │
├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ null ┆ zero │
├╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ zero ┆ 6.0  │
└──────┴──────┘