import numpy as np from collections import Counter data = np.array([1.1,2,3,4,4,5]) Counter(data) # {label:sum(label)} #简单方法 sum(data==4)