In this example we will show how to filter a NumPy array using a boolean index list in Python.
Source Code
import numpy as np
a = np.array([5, 6, 7, 8, 9, 10, 11, 12])
b = [True, False, True, False, True, False, True, False]
c = a[b]
print(c)
Output:
[ 5 7 9 11]