0

I know I can get the minimum value of a numpy matrix column-wise using:

my_array.min(axis=0)

But is there any way to efficiently get equivalent index/row instead of the values them-self? For instance:

my_array = [[10, 2, 3], [1, 3, 10], [20, 19, 0]]

I expect to get something like this:

[1, 0, 2] >> location of minimum values instead of values.

usamazf
  • 3,195
  • 4
  • 22
  • 40

1 Answers1

1

You can use argmin instead

>>> my_array = [[10, 2, 3], [1, 3, 10], [20, 19, 0]]
>>> a=np.array(my_array)
>>> np.argmin(a, axis=0)
array([1, 0, 2])
grodzi
  • 5,633
  • 1
  • 15
  • 15