Apply the OR logical horizontally across columns
Description
Apply the OR logical horizontally across columns
Usage
pl$any_horizontal(...)
Arguments
…
|
\<dynamic-dots \> Columns to aggregate horizontally. Accepts
expressions. Strings are parsed as column names, other non-expression
inputs are parsed as literals.
|
Details
Kleene
logic is used to deal with nulls: if the column contains any null
values and no FALSE
values, the output is null.
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(
a = c(FALSE, FALSE, TRUE, TRUE, FALSE, NA),
b = c(FALSE, TRUE, TRUE, NA, NA, NA),
c = c("u", "v", "w", "x", "y", "z")
)
df$with_columns(
any = pl$any_horizontal("a", "b")
)
#> shape: (6, 4)
#> ┌───────┬───────┬─────┬───────┐
#> │ a ┆ b ┆ c ┆ any │
#> │ --- ┆ --- ┆ --- ┆ --- │
#> │ bool ┆ bool ┆ str ┆ bool │
#> ╞═══════╪═══════╪═════╪═══════╡
#> │ false ┆ false ┆ u ┆ false │
#> │ false ┆ true ┆ v ┆ true │
#> │ true ┆ true ┆ w ┆ true │
#> │ true ┆ null ┆ x ┆ true │
#> │ false ┆ null ┆ y ┆ null │
#> │ null ┆ null ┆ z ┆ null │
#> └───────┴───────┴─────┴───────┘