Counter对numpy数组进行统计
生活随笔
收集整理的這篇文章主要介紹了
Counter对numpy数组进行统计
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. 通過counter庫對數組內的元素進行頻數統計。
In [1]: import numpy as npIn [2]: from collections import CounterIn [3]: a = np.array([[1,2],[3,4]])In [4]: Counter(a.flatten()) Out[4]: Counter({1: 1, 2: 1, 3: 1, 4: 1})In [5]: b = np.array([[1,1],[3,4]]) In [6]: Counter(b.flatten()) Out[6]: Counter({1:2, 3: 1, 4: 1})2. 參考
- ?https://segmentfault.com/q/1010000016716175?utm_source=tag-newest
總結
以上是生活随笔為你收集整理的Counter对numpy数组进行统计的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: maya海龟烘焙法线_maya法线烘焙
- 下一篇: 几个Python小案例, 爱上Pytho