numpy.argmin() in Python Last Updated : 08 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The numpy.argmin() method returns indices of the min element of the array in a particular axis. Syntax : numpy.argmin(array, axis = None, out = None) Parameters : array : Input array to work on axis : [int, optional]Along a specified axis like 0 or 1 out : [array optional]Provides a feature to insert output to the out array and it should be of appropriate shape and dtype Return : Array of indices into the array with same shape as array.shape with the dimension along axis removed. Code 1 : Python # Python Program illustrating # working of argmin() import numpy as geek # Working on 1D array array = geek.arange(8) print("INPUT ARRAY : \n", array) # returning Indices of the min element # as per the indices print("\nIndices of min element : ", geek.argmin(array, axis=0)) Output : INPUT ARRAY : [0 1 2 3 4 5 6 7] Indices of min element : 0 Code 2 : Python # Python Program illustrating # working of argmin() import numpy as geek # Working on 2D array array = geek.random.randint(16, size=(4, 4)) print("INPUT ARRAY : \n", array) # returning Indices of the min element # as per the indices ''' [[ 8 13 5 0] [ 0 2 5 3] [10 7 15 15] [ 3 11 4 12]] ^ ^ ^ ^ 0 2 4 0 - element 1 1 3 0 - indices ''' print("\nIndices of min element : ", geek.argmin(array, axis = 0)) Output : INPUT ARRAY : [[ 8 13 5 0] [ 0 2 5 3] [10 7 15 15] [ 3 11 4 12]] Indices of min element : [1 1 3 0] Code 3 : Python # Python Program illustrating # working of argmin() import numpy as geek # Working on 2D array array = geek.arange(10).reshape(2, 5) print("array : \n", array) array[0][0] = 10 array[1][1] = 1 array[0][1] = 1 print("\narray : \n", array) # Returns min element print("\narray : ", geek.argmin(array)) # First occurrence of an min element is given print("\nmin ELEMENT INDICES : ", geek.argmin(array, axis = 0)) Output : array : [[0 1 2 3 4] [5 6 7 8 9]] array : [[10 1 2 3 4] [ 5 1 7 8 9]] array : 1 min ELEMENT INDICES : [1 0 0 0 0] Comment More infoAdvertise with us Next Article numpy.argmin() in Python M Mohit Gupta_OMG Improve Article Tags : Python Python-numpy Python numpy-Sorting Searching Practice Tags : python Similar Reads numpy.amin() in Python The numpy.amin() function returns minimum of an array or minimum along axis(if mentioned). Syntax : numpy.amin(arr, axis = None, out = None, keepdims = <class numpy._globals._NoValue>) Parameters : arr : [array_like]input dataaxis : [int or tuples of int]axis along which we want the min value. 2 min read numpy.argmax() in Python The numpy.argmax() function returns indices of the max element of the array in a particular axis. Syntax : numpy.argmax(array, axis = None, out = None) Parameters : array : Input array to work on axis : [int, optional]Along a specified axis like 0 or 1 out : [array optional]Provides a feature to ins 3 min read numpy.fmin() in Python numpy.fmin() function is used to compute element-wise minimum of array elements. This function compare two arrays and returns a new array containing the element-wise minima. If one of the elements being compared is a NaN, then the non-nan element is returned. If both elements are NaNs then the first 2 min read numpy.amax() in Python The numpy.amax() method returns the maximum of an array or maximum along the axis(if mentioned). Syntax: numpy.amax(arr, axis = None, out = None, keepdims = <class numpy._globals._NoValue>) Parameters - arr : [array_like] input dataaxis : [int or tuples of int] axis along which we want the ma 2 min read numpy.arange() in Python numpy.arange() function creates an array of evenly spaced values within a given interval. It is similar to Python's built-in range() function but returns a NumPy array instead of a list. Let's understand with a simple example:Pythonimport numpy as np #create an array arr= np.arange(5 , 10) print(arr 2 min read numpy.argwhere() in Python numpy.argwhere() function is used to find the indices of array elements that are non-zero, grouped by element. Syntax : numpy.argwhere(arr) Parameters : arr : [array_like] Input array. Return : [ndarray] Indices of elements that are non-zero. Indices are grouped by element. Code #1 : Python3 # Pytho 1 min read numpy.nanmin() in Python numpy.nanmin()function is used when to returns minimum value of an array or along any specific mentioned axis of the array, ignoring any Nan value. Syntax : numpy.nanmin(arr, axis=None, out=None) Parameters : arr :Input array. axis :Axis along which we want the min value. Otherwise, it will consider 2 min read numpy.nanargmin() in Python The numpy.nanargmin() function returns indices of the min element of the array in a particular axis ignoring NaNs. The results cannot be trusted if a slice contains only NaNs and Infs. Syntax:  numpy.nanargmin(array, axis = None) Parameters : array : Input array to work on axis : [int, optional]A 2 min read numpy.fmax() in Python numpy.fmax() function is used to compute element-wise maximum of array elements. This function compare two arrays and returns a new array containing the element-wise maxima. If one of the elements being compared is a NaN, then the non-nan element is returned. If both elements are NaNs then the first 2 min read numpy.clip() in Python numpy.clip() function is used to Clip (limit) the values in an array. Given an interval, values outside the interval are clipped to the interval edges. For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, and values larger than 1 become 1. Syntax : numpy.clip(a, a_min, 2 min read Like