Skip to content

Check if elements are finite

Description

Check if elements are finite

Usage

<Expr>$is_finite()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(a = c(1, 2), b = c(3, Inf))
df$with_columns(
  a_finite = pl$col("a")$is_finite(),
  b_finite = pl$col("b")$is_finite()
)
#> shape: (2, 4)
#> ┌─────┬─────┬──────────┬──────────┐
#> │ a   ┆ b   ┆ a_finite ┆ b_finite │
#> │ --- ┆ --- ┆ ---      ┆ ---      │
#> │ f64 ┆ f64 ┆ bool     ┆ bool     │
#> ╞═════╪═════╪══════════╪══════════╡
#> │ 1.0 ┆ 3.0 ┆ true     ┆ true     │
#> │ 2.0 ┆ inf ┆ true     ┆ false    │
#> └─────┴─────┴──────────┴──────────┘