Skip to content

Drop all floating point NaN values

Description

The original order of the remaining elements is preserved. A NaN value is not the same as a null value. To drop null values, use $drop_nulls().

Usage

<Expr>$drop_nans()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(a = c(1, NA, 3, NaN))
df$select(pl$col("a")$drop_nans())
#> shape: (3, 1)
#> ┌──────┐
#> │ a    │
#> │ ---  │
#> │ f64  │
#> ╞══════╡
#> │ 1.0  │
#> │ null │
#> │ 3.0  │
#> └──────┘