Apply logical OR on a column
Description
Check if any boolean value in a Boolean column is TRUE
.
Usage
<Expr>$any(..., ignore_nulls = TRUE)
Arguments
…
|
Ignored. |
ignore_nulls
|
If TRUE (default), ignore null values. If
FALSE ,
Kleene
logic is used to deal with nulls: if the column contains any null
values and no TRUE values, the output is null.
|
Value
A logical value
Examples
library("polars")
df = pl$DataFrame(
a = c(TRUE, FALSE),
b = c(FALSE, FALSE),
c = c(NA, FALSE)
)
df$select(pl$col("*")$any())
#> shape: (1, 3)
#> ┌──────┬───────┬───────┐
#> │ a ┆ b ┆ c │
#> │ --- ┆ --- ┆ --- │
#> │ bool ┆ bool ┆ bool │
#> ╞══════╪═══════╪═══════╡
#> │ true ┆ false ┆ false │
#> └──────┴───────┴───────┘
# If we set ignore_nulls = FALSE, then we don't know if any values in column
# "c" is TRUE, so it returns null
df$select(pl$col("*")$any(ignore_nulls = FALSE))
#> shape: (1, 3)
#> ┌──────┬───────┬──────┐
#> │ a ┆ b ┆ c │
#> │ --- ┆ --- ┆ --- │
#> │ bool ┆ bool ┆ bool │
#> ╞══════╪═══════╪══════╡
#> │ true ┆ false ┆ null │
#> └──────┴───────┴──────┘