Quantcast
Channel: Filter numpy array by two conditions. More than one element is ambiguous - Stack Overflow
Browsing all 3 articles
Browse latest View live

Answer by mgilson for Filter numpy array by two conditions. More than one...

python's and looks at the boolean value on either side of the condition. Because of design decisions in numpy, arrays with more than 1 value don't have a boolean value (it raises ValueError as you've...

View Article



Answer by John Zwinck for Filter numpy array by two conditions. More than one...

You need to use & instead of and with NumPy arrays:mask = (data[:,0] == ptype) & (data[:,8] <= radius)data[mask,7].sum()

View Article

Filter numpy array by two conditions. More than one element is ambiguous

I have a numpy array which I need to filter and perform a sum on. Similar to my previous question, although this one needs to be filtered by two conditions.Need to return the sum of column 7 where...

View Article
Browsing all 3 articles
Browse latest View live




Latest Images