I have two arrays, and I want to select a section of one of them based on values of the other. I know how to do this in a few lines, but I want to know if there is a neater way, in one line, to do this. This is how I do it which is long and ugly.
lower = some_value; upper = another_value
a = [some numpy array]; b = [another numpy array]
b_select = []
for i in range(len(a)):
if a[i] < lower or a[i] > upper:
b_select.append(b[i])
So basically my question is, can I get b_select in one line, instead of the last 4 lines?
Any advice would be much appreciated. For info I am doing this in Python 2.7.