How to use numpy.where with logical operators
Here are two ways: In [1]: my_array = arange(10) In [2]: where((my_array > 3) & (my_array < 7)) Out[2]: (array([4, 5, 6]),) In [3]: where(logical_and(my_array > 3, my_array < 7)) Out[3]: (array([4, 5, 6]),) For the first (replacing and with &), be careful to add parentheses appropriately: & has higher precedence than the comparison operators. … Read more