Intersect two boolean arrays for True

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.

Leave a Comment

tech