Apply the AND logical rowwise
Description
Apply the AND logical rowwise
Usage
pl$all_horizontal(...)
Arguments
…
|
Columns to concatenate into a single string column. Accepts expressions. Strings are parsed as column names, other non-expression inputs are parsed as literals. |
Value
Expr
Examples
library("polars")
df = pl$DataFrame(
a = c(TRUE, FALSE, NA, NA),
b = c(TRUE, FALSE, NA, NA),
c = c(TRUE, FALSE, NA, TRUE)
)
df
#> shape: (4, 3)
#> ┌───────┬───────┬───────┐
#> │ a ┆ b ┆ c │
#> │ --- ┆ --- ┆ --- │
#> │ bool ┆ bool ┆ bool │
#> ╞═══════╪═══════╪═══════╡
#> │ true ┆ true ┆ true │
#> │ false ┆ false ┆ false │
#> │ null ┆ null ┆ null │
#> │ null ┆ null ┆ true │
#> └───────┴───────┴───────┘
#> shape: (4, 4)
#> ┌───────┬───────┬───────┬───────┐
#> │ a ┆ b ┆ c ┆ all │
#> │ --- ┆ --- ┆ --- ┆ --- │
#> │ bool ┆ bool ┆ bool ┆ bool │
#> ╞═══════╪═══════╪═══════╪═══════╡
#> │ true ┆ true ┆ true ┆ true │
#> │ false ┆ false ┆ false ┆ false │
#> │ null ┆ null ┆ null ┆ null │
#> │ null ┆ null ┆ true ┆ null │
#> └───────┴───────┴───────┴───────┘
# drop rows that have at least one missing value
# == keep rows that only have non-missing values
df$filter(
pl$all_horizontal(pl$all()$is_not_null())
)
#> shape: (2, 3)
#> ┌───────┬───────┬───────┐
#> │ a ┆ b ┆ c │
#> │ --- ┆ --- ┆ --- │
#> │ bool ┆ bool ┆ bool │
#> ╞═══════╪═══════╪═══════╡
#> │ true ┆ true ┆ true │
#> │ false ┆ false ┆ false │
#> └───────┴───────┴───────┘