I\'m new to NumPy, and I\'ve encountered a problem with running some conditional statements on numpy arrays. Let\'s say I have 3 numpy arrays that look like this:
a:
You can use numpy.where:
numpy.where
np.where((a > 3) & (b > 8), c + b*2, c) #array([[ 0, 18, 0, 0], # [ 0, 0, 0, 0], # [ 0, 0, 0, 0]])
Or arithmetically:
c + b*2 * ((a > 3) & (b > 8)) #array([[ 0, 18, 0, 0], # [ 0, 0, 0, 0], # [ 0, 0, 0, 0]])