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

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

$
0
0

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 column 0 == ptype AND column 8 == radius.

np.sum(data[data[:,0] == ptype and data[data[:,8] <= radius],7])

I get the following error:

The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Any ideas?


Viewing all articles
Browse latest Browse all 3

Trending Articles