polars.Series.filter
-
Filter elements by a boolean mask.
The original order of the remaining elements is preserved.
Elements where the filter does not evaluate to True are discarded, including nulls.
- 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 ]
Series.filter(
predicate: Series | Iterable[bool],
) → Self
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/series/api/polars.Series.filter.html