how to get the count of particular element in array python code example
Example 1: python how to count items in array
myArray = [1, 2, 3]
len(myArray)
#output
3
Example 2: python count of values in array
import numpy as np
y = np.array([0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1])
num_zeros = (y == 0).sum()
num_ones = (y == 1).sum()