polars.Expr.list.contains#

Expr.list.contains(
item: float | str | bool | int | date | datetime | time | Expr,
) Expr[source]#

Check if sublists contain the given item.

Parameters:
item

Item that will be checked for membership

Returns:
Expr

Expression of data type Boolean.

Examples

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