# dask.bag.Bag.filter

#### Bag.filter(predicate)

Filter elements in collection by a predicate function.

```pycon
>>> def iseven(x):
...     return x % 2 == 0
```

```pycon
>>> import dask.bag as db
>>> b = db.from_sequence(range(5))
>>> list(b.filter(iseven))
[0, 2, 4]
```

<!-- !! processed by numpydoc !! -->
