I am trying to find the last occurring max value in an array. The following code is what I have thus far:
a = np.matrix([[1, 2, 3, 4, 5], [99, 7, 8, 9, 10], [99, 12, 13, 99, 15], [16, 99, 18, 19, 20], [99, 22, 23, 24, 99]])
m, n = a.shape
out = np.full((n), np.nan)
for i in range(n):
out[i] = np.argwhere(a[:, i] == 99)
However it keeps on popping up with an error as shown:
The aim of this code is to go through each column and find the last occurrence of the maximum value ( in this case 99 ) so the result should look something like [4, 3, 0, 2, 4]
Thanks in advance