标签: python arrays list numpy indexing
我有一个数字数组,最大值可能会多次出现。
是否可以通过使用像numpy.argmax这样的东西来找到最后一次出现的最大值的索引?
或者,更好的是,是否可以获得数组中所有最大值出现的索引列表?
答案 0 :(得分: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])