Check if elements of an expression are present in another expression
Description
Check if elements of an expression are present in another expression
Usage
<Expr>$is_in(other, ..., nulls_equal = FALSE)
Arguments
other
|
Accepts expression input. Strings are parsed as column names. |
…
|
These dots are for future extensions and must be empty. |
nulls_equal
|
A bool to indicate treating null as a distinct value. If
TRUE , null values will not propagate.
|
Value
A polars expression
Examples
library("polars")
df <- pl$DataFrame(
sets = list(1:3, 1:2, 9:10),
optional_members = 1:3
)
df$with_columns(
contains = pl$col("optional_members")$is_in("sets")
)
#> shape: (3, 3)
#> ┌───────────┬──────────────────┬──────────┐
#> │ sets ┆ optional_members ┆ contains │
#> │ --- ┆ --- ┆ --- │
#> │ list[i32] ┆ i32 ┆ bool │
#> ╞═══════════╪══════════════════╪══════════╡
#> │ [1, 2, 3] ┆ 1 ┆ true │
#> │ [1, 2] ┆ 2 ┆ true │
#> │ [9, 10] ┆ 3 ┆ false │
#> └───────────┴──────────────────┴──────────┘