9951 explained code solutions for 126 technologies


python-numpyHow to use Numpy bincount to find value occurrences


import numpy as np

array = np.array([1,2,3,3,2,2,3])
counts = np.bincount(array)ctrl + c
import numpy as np

load Numpy module for Python

np.array

declare Numpy array

.bincount

count number of occurrences of each value in array of non-negative ints

array

array to count values in

counts

will contain final array with counted values