I'm trying to get a sum of Min or Max value in each row. If the number on first index is bigger than 12, return the max number in the row, else return min number in the row. Note that in below given sample, it's a 4 x 3 2D array. However I want my code to work given any array size or shape.
import numpy as np
arr = np.array([[11, 12, 13],
[14, 15, 16],
[17, 15, 11],
[12, 14, 15]])
i_max = np.amax(arr,axis=1)
i_min = np.amin(arr,axis=1)
print(i_max)
print(i_min)
So far I can only get to the Min or Max number in each row using amax and amin. What I'm lacking is to access first value in each row and use if else statement to compare the size to 12. Can anyone give a hint.
The correct output for given sample should be 11 + 16 + 17 + 12 = 56
