Is there a more optimal approach to check if the elements in a list dtype column are in another input list?
import polars as pl
df = pl.DataFrame(
{"sets": [[1, 2, 3], [1, 2], [9, 10]]}
)
df.with_columns(
(
pl.col("sets").list.set_intersection([1,7]).list.len() != 0
).alias("check")
)
shape: (3, 2)
┌───────────┬───────┐
│ sets ┆ check │
│ --- ┆ --- │
│ list[i64] ┆ bool │
╞═══════════╪═══════╡
│ [1, 2, 3] ┆ true │
│ [1, 2] ┆ true │
│ [9, 10] ┆ false │
└───────────┴───────┘