Skip to content Skip to sidebar Skip to footer

2d Argmax On A Numpy Array

Starting with a numpy array v: v = \ np.array([[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 1],

Solution 1:

You just want to range through the columns

v[v.argmax(axis=0), np.arange(v.shape[1])] *= 100

Post a Comment for "2d Argmax On A Numpy Array"