Consider some array arr and advanced indexing mask mask:
arr
mask
import numpy as np arr = np.arange(4).reshape(2, 2) mask = A < 2