在Python中查找给定数组中的最小值索引

use*_*019 15 python arrays numpy

我需要找到数组中出现的多个最小值的索引.我很熟悉,np.argmin但它给了我一个数组中第一个最小值的索引.例如.

a = np.array([1,2,3,4,5,1,6,1])    
print np.argmin(a)
Run Code Online (Sandbox Code Playgroud)

这给了我0,而不是我期待的,0,5,7.

谢谢!

Tom*_*fty 23

这应该做的伎俩:

a = np.array([1,2,3,4,5,1,6,1]) 
print np.where(a == a.min())
Run Code Online (Sandbox Code Playgroud)

在这种情况下,argmin不会像您期望的那样返回列表.