2011-08-12 11 views

回答

8
import numpy as np 

a = np.array((1,2,3,2,3,2,1,3)) 

occurences = np.where(a == a.max()) 

# occurences == array([2, 4, 7]) 
+0

完美!非常感谢您的及时回复:) – Liw

+4

我不确定这是真实的更新版本,但与v1.4.0,应该有'occurences = np.where(a == a.max())[ 0]',以便在出现的时候获得一个数组而不是元组。 – dtlussier

相关问题