polars.Series.filter#

Series.filter(predicate: Series | list[bool]) Self[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
]