polars.Series.filter#

Series.filter(predicate: polars.internals.series.series.Series | list[bool]) Series[source]#

Filter elements by a boolean mask.

Parameters:
predicate

Boolean mask.

Examples

>>> s = pl.Series("a", [1, 2, 3])
>>> mask = pl.Series("", [True, False, True])
>>> s.filter(mask)
shape: (2,)
Series: 'a' [i64]
[
        1
        3
]