Joe Flip Joe Flip - 6 months ago 57
Python Question

Python: Adding boolean Numpy arrays

I have three lists as such:

a = np.array([True, True, False, False])
b = np.array([False, False, False, False])
c = np.array([False, False, False, True])

I want to add the arrays so that the new array only has
if all the corresponding elements are
. For example, the output should be:

d = np.array([True, True, False, True])

d = np.add(a,b,c)

d = np.array([True, True, False, False])

Why is this and how can I fix it? Thanks!

v2b v2b
>>> a=[True, True, False, False]
>>> b=[False, False, False, False]
>>> c=[False, False, False, True]
>>> map(sum, zip(a,b,c))
[1, 1, 0, 1]