I know that in Numpy you can mask an array based on a condition. For example, if I want a masked array for all values greater than 0.
arr[arr>0]
But I want to have two conditions for the mask. Intuitively, this would look like:
arr[arr>0 and arr<1]
but the compiler pops an error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I know I can use a for loop to solve this:
masked=np.array([i if(i>0 and i<1) for i in mask])
but is there a more elegant solution using something that's built-in for Numpy?