0

i have a multi dimensional array in python like this:

array[x,y]=value

both x and y can start from 0 and end in 300

array[0,0]=100
array[1,0]=98
array[2,0]=120
array[3,0]=140
array[4,0]=124
# array[x,y]=value
array[300,299]=200
array[300,300]=170

how can i get the x,y of higest value of it?

i tryed to do a max() but i can only get the value , not x and y

Jasar Orion
  • 626
  • 7
  • 26

1 Answers1

0

you may use:

from numpy import unravel_index

a = np.array([[1, 2, 3, 4, 5], [3, 13, 2, 3, 4]])

unravel_index(a.argmax(), a.shape)

output:

(1, 1)

this is just an example for a 2d array but this works well also with a multi dimensional array

kederrac
  • 16,819
  • 6
  • 32
  • 55