Replacing Numpy Array With Max Value January 26, 2024 Post a Comment 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 maxSolution 1: You should usenp.max(a, axis=1) CopyLink to documentationSolution 2: another implementation you can do thisnp.array([max(i) for i in a]) Copy Share Post a Comment for "Replacing Numpy Array With Max Value"
Post a Comment for "Replacing Numpy Array With Max Value"