统计numpy数组中最频繁出现的值
arr = np.array([[1,2,100,4,5,6],[1,1,100,3,5,5],[2,2,4,4,6,6]])
方法一:
count = np.bincount(arr[:,2]) # 找出第3列最频繁出现的值 value = np.argmax(count)
方法二:
from collections import Counter value = Counter(arr[:,2]).most_common()
作者:jsp
-------------------------------------------
个性签名:无论在哪里做什么,只要坚持服务、创新、创造价值,其它的东西自然都会来的。
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!