Suppose I have the following array:
array = numpy.array([[[7.1, 4.5, 2.1], [0.9, 0.6, 10.1]],
[[11.0, 5.4, 4.3], [6.7, 0.3, 8.2]]])
I am trying to create a function that allows me to find the element with the highest sum value and return its position in the form (row, column), probably as a tuple. In this case, the desired output would be (1,0) as the element in the second row, first column has the highest sum value.
This has been my approach, but I can't seem to figure out how to get the output I desire. I've looked through the NumPy documentation extensively and tried many variations of .max and .where commands.
def function(array):
for row in range(len(array)):
for column in range(len(array[row])):
total = (array[row, column, 0] + array[row, column, 1] + array[row, column, 2])
array[row, column, 0] = total
array[row, column, 1] = total
array[row, column, 2] = total
return ???
My thought was to reassign the total value to all the elements within each list in the array then use something like numpy.max to give me the position of the maximum value, but that appears to produce an index value outside of the range I'm expecting.
Any advice is appreciated!
(row, column), iteratively checking if the current total is larger and then overwrite those values if a higher total is found.