polars.internals.expr.ExprListNameSpace.contains

ExprListNameSpace.contains(item: Union[float, str, bool, int, datetime.date, datetime.datetime]) polars.internals.expr.Expr

Check if sublists contain the given item.

Parameters
item

Item that will be checked for membership

Returns
Boolean mask

Examples

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