Skip to content Skip to sidebar Skip to footer

Replacing Numpy Array With Max Value

I have an array, a = np.array([[0,9,8],[5,6,4]]) how to replace the each array in axis 1 with the max value of its array? excepting output- a = np.array([9,6]) where 9 is the max

Solution 1:

You should use

np.max(a, axis=1)

Link to documentation

Solution 2:

Post a Comment for "Replacing Numpy Array With Max Value"