Skip to content

Check if elements are NaN

Source code

Description

Returns a boolean Series indicating which values are NaN.

Usage

<Expr>$is_nan()

Value

Expr

Examples

library(polars)

pl$DataFrame(list(alice = c(0, NaN, NA, Inf, -Inf)))$
  with_columns(nan = pl$col("alice")$is_nan())
#> shape: (5, 2)
#> ┌───────┬───────┐
#> │ alice ┆ nan   │
#> │ ---   ┆ ---   │
#> │ f64   ┆ bool  │
#> ╞═══════╪═══════╡
#> │ 0.0   ┆ false │
#> │ NaN   ┆ true  │
#> │ null  ┆ null  │
#> │ inf   ┆ false │
#> │ -inf  ┆ false │
#> └───────┴───────┘