1a = numpy.array([0, 3, 0, 1, 0, 1, 2, 1, 0, 0, 0, 0, 1, 3, 4])
2unique, counts = numpy.unique(a, return_counts=True)
3dict(zip(unique, counts))
4
5# {0: 7, 1: 4, 2: 1, 3: 2, 4: 1}
6
1import numpy as np
2y = np.array([0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1])
3num_zeros = (y == 0).sum()
4num_ones = (y == 1).sum()
5
1# Our array
2arr = [82, 49, 82, 82, 41, 82, 15, 63, 38, 25]
3
4# let's print the number of 82 in our array/list
5print(arr.count(82))
6
7# it will print : 4