I have a pandas dataframe and want to extract the rows that match certain criteria.
In simple cases, I would make boolean 'masks' as shown below, and combine those with `&` and `|`.

```
import pandas as pd

foo = {
  "A": [1,2,3,4],
  "B": [1,2,3,5],
  "C": [2,4,6,8],
  "D": [5,5,5,1]}

df = pd.DataFrame(data=foo)

mask1 = df["D"] > 1  # True for rows 0,1,2
mask2 = df["B"] % 2 == 0 # True for row 1
mask3 = df["A"] == df["B"]  # True for rows 0,1,2

```

However, in this case, I'd like to match rows for which *n* or more such expressions are true. In the above example, I'd like rows that match at least 2 of the criteria. I realize of course that this can be achieved by something like (1 AND 2) OR (1 AND 3) OR (2 AND 3), but that quickly becomes untractable to write and I was wondering if a more elegant solution exists?