Python| numpy matrix.argmin()
借助Numpy matrix.argmax()
方法,我们能够找到给定矩阵中具有一维或多维的最小元素的索引值。
Syntax : matrix.argmin()
Return : Return index number of minimum elements in matrix
示例 #1:
在这个例子中,我们可以看到在matrix.argmax()
方法的帮助下,我们能够找到给定矩阵中最小元素的索引。
# import the important module in python
import numpy as np
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3, 4]')
# applying matrix.argmin() method
geeks = gfg.argmin()
print(geeks)
输出:
0
示例 #2:
# import the important module in python
import numpy as np
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3; 4, -5, 6; 7, 8, 9]')
# applying matrix.argmin() method
geeks = gfg.argmin()
print(geeks)
输出:
4