removing pairs of elements from numpy arrays that are NaN (or another value) in Python,a[~(a == 5).any(1)]