Say I have an array:
import numpy as np
arr = np.random.randint(0, 5, 20)
then arr>3 results in an array of type bool with shape (20,). How can I most efficiently do the same thing with the "contains" operator? The simple
arr in [2, 4]
will result in "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()". Is there another way than
np.array([ x in [2, 4] for x in arr])
?