Parameter Name:numpy.argwhere()
Description : Find the indices of array elements that are non-zero, grouped by element.
Parameter Name: numpy.nonzero()
Description : Return the indices of the elements that are non-zero.
Parameter Name: numpy.flatnonzero()
Description : Return indices that are non-zero in the flattened version of a.
Parameter Name: numpy.where()
Description : Return elements chosen from x or y depending on condition.
Parameter Name: numpy.searchsorted()
Description : Find indices where elements should be inserted to maintain order.
Parameter Name: numpy.extract()
Description : Return the elements of an array that satisfy some condition.
The first step would be to give syntax
command:
numpy.argmax()
Example :
Code :
import numpy as np
array =np.arange(16).reshape(4, 4)
print("INPUT ARRAY : ", array)
print("Max element : ", np.argmax(array))
print(("Indices of Max element : " , np.argmax(array, axis=0)))
print(("Indices of Max element : " , np.argmax(array, axis=1)))
Output :
Example :
Code :
import numpy as np
array = [np.nan, 5,6,7,8]
print("INPUT ARRAY 1 : ", array)
array2 = np.array([[np.nan, 8], [4,4]])
print(("Indices of max in array1 : " , np.nanargmax(array)))
print("INPUT ARRAY 2 : ", array2)
print(("Indices of max in array2 : " , np.nanargmax(array2)))
print(("Indices at axis 1 of array2 : " , np.nanargmax(array2, axis = 1)))
Output :
Comments