polars.Series.arr.contains#

Series.arr.contains(item: IntoExpr, *, nulls_equal: bool = True) Series[source]#

Check if sub-arrays contain the given item.

Parameters:
item

Item that will be checked for membership

nulls_equalbool, default True

If True, treat null as a distinct value. Null values will not propagate.

Returns:
Series

Series of data type Boolean.

Examples

>>> s = pl.Series(
...     "a", [[3, 2, 1], [1, 2, 3], [4, 5, 6]], dtype=pl.Array(pl.Int32, 3)
... )
>>> s.arr.contains(1)
shape: (3,)
Series: 'a' [bool]
[
    true
    true
    false
]