The numpy.ndarray.argmin() is a numpy method that returns the index of the minimum element in the given array along a given axis. It returns the position/index of the minimum value found in the array.
Example 1: Finding the index of the minimum value in a 1D array
import numpy as np
arr = np.array([2, 5, 1, 7, 6])
index = arr.argmin()
print(index)
Output:
2
Example 2: Finding the index of the minimum value in a 2D array along a specific axis
import numpy as np
arr = np.array([[4, 5, 6], [1, 2, 3], [7, 8, 9]])
index = arr.argmin(axis=0)
print(index)
Output:
[1 1 1]
This function is a part of numpy library.
Python ndarray.argmin - 18 examples found. These are the top rated real world Python examples of numpy.ndarray.argmin extracted from open source projects. You can rate examples to help us improve the quality of examples.