polars.Expr.is_in#

Expr.is_in(other: Union[Expr, Sequence[Any], str, Series]) Expr[source]#

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

Parameters:
other

Series or sequence of primitive type.

Returns:
Expr that evaluates to a Boolean Series.

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    │
└──────────┘