polars.Expr.drop_nans#

Expr.drop_nans() Expr[source]#

Drop floating point NaN values.

Warning

Note that NaN values are not null values! To drop null values, use drop_nulls().

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [8, 9, 10, 11],
...         "b": [None, 4.0, 4.0, float("nan")],
...     }
... )
>>> df.select(pl.col("b").drop_nans())
shape: (3, 1)
┌──────┐
│ b    │
│ ---  │
│ f64  │
╞══════╡
│ null │
├╌╌╌╌╌╌┤
│ 4.0  │
├╌╌╌╌╌╌┤
│ 4.0  │
└──────┘