Skip to content

Check if elements are NULL

Description

Check if elements are NULL

Usage

<Expr>$is_null()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(
  a = c(1, 2, NA, 1, 5),
  b = c(1, 2, NaN, 1, 5)
)
df$with_columns(
  a_null = pl$col("a")$is_null(),
  b_null = pl$col("b")$is_null()
)
#> shape: (5, 4)
#> ┌──────┬─────┬────────┬────────┐
#> │ a    ┆ b   ┆ a_null ┆ b_null │
#> │ ---  ┆ --- ┆ ---    ┆ ---    │
#> │ f64  ┆ f64 ┆ bool   ┆ bool   │
#> ╞══════╪═════╪════════╪════════╡
#> │ 1.0  ┆ 1.0 ┆ false  ┆ false  │
#> │ 2.0  ┆ 2.0 ┆ false  ┆ false  │
#> │ null ┆ NaN ┆ true   ┆ false  │
#> │ 1.0  ┆ 1.0 ┆ false  ┆ false  │
#> │ 5.0  ┆ 5.0 ┆ false  ┆ false  │
#> └──────┴─────┴────────┴────────┘