np.bincount
#NumPy
https://numpy.org/doc/stable/reference/generated/numpy.bincount.html
Count number of occurrences of each value in array of non-negative ints.
「非負の整数の配列の各値の登場回数を数える」
collections.Counter
に近い印象
code:examples.py
>> np.bincount(np.arange(5)) # 0, 1, 2, 3, 4
array(
1, 1, 1, 1, 1
)
>> np.bincount(np.array(
0, 1, 1, 3, 2, 1, 7
))
array(
1, 3, 1, 1, 0, 0, 0, 1
)