WeCodeAcademy

Filtering with Boolean Masks

A comparison such as a > 3 gives an array of True/False, called a mask. Put the mask inside square brackets to keep only the matching values. Combine masks with & (and) and | (or), each condition in parentheses. np.where picks between two values.

Examplepython
Open in editor »
Quick check

What does `(a > 3).sum()` count?

Your turn: write the code

Print only the scores that are 60 or higher.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.