Suppose I have a numpy array x = [1, 2, 3, 4, 5, ...] and I want to replace values that are not in the list a = [1, 3, 5, ...] with 0.
I tried x[x not in a] = 0 but I got the error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Anyone know the proper way that doesn't require spelling out the conditions?