polars.Expr.is_in#

Expr.is_in(other: Expr | Collection[Any] | Series) Self[source]#

Check if elements of this expression are present in the other Series.

Parameters:
other

Series or sequence of primitive type.

Returns:
Expr

Expression of data type Boolean.

Examples

>>> df = pl.DataFrame(
...     {"sets": [[1, 2, 3], [1, 2], [9, 10]], "optional_members": [1, 2, 3]}
... )
>>> df.select([pl.col("optional_members").is_in("sets").alias("contains")])
shape: (3, 1)
┌──────────┐
│ contains │
│ ---      │
│ bool     │
╞══════════╡
│ true     │
│ true     │
│ false    │
└──────────┘