numpy count the number of 1s in array

a = numpy.array([0, 3, 0, 1, 0, 1, 2, 1, 0, 0, 0, 0, 1, 3, 4])
unique, counts = numpy.unique(a, return_counts=True)
dict(zip(unique, counts))
{0: 7, 1: 4, 2: 1, 3: 2, 4: 1}

Here is what the above code is Doing:
1. numpy.unique(a) returns a sorted unique list of elements in a.
2. numpy.unique(a, return_counts=True) returns a tuple of two arrays, the first being the sorted unique list of elements in a, and the second being the number of times each element occurs in a.
3. dict(zip(unique, counts)) returns a dictionary where the keys are the unique elements in a, and the values are the number of times each element occurs in a.