Skip to content Skip to sidebar Skip to footer

Intersect Two Boolean Arrays For True

Having the numpy arrays a = np.array([ True, False, False, True, False], dtype=bool) b = np.array([False, True, True, True, False], dtype=bool) how can I make the intersectio

Solution 1:

Numpy provides logical_and() for that purpose:

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

c = np.logical_and(a, b)
# array([False, False, False, True, False], dtype=bool)

More at Numpy Logical operations.

Post a Comment for "Intersect Two Boolean Arrays For True"