I have an array and want ot extract all entries which are in a specific range
x = np.array([1,2,3,4])
condition = x<=4 and x>1
x_sel = np.extract(condition,x)
But this does not work. I'm getting
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
If I'm doing the same without the and and checking for example only one condition
x = np.array([1,2,3,4])
condition = x<=4
x_sel = np.extract(condition,x)
everything works... Of courese I could just apply the procedure twice with one condition, but isn't there a solution to do this in one line?
Many thanks in advance