import numpy as np
A = np.array([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 40, 50]) key, cnt = np.unique(A, return_counts = True)
print(key) print(cnt)
[ 1 2 3 4 5 6 9 40 50] [2 1 2 1 3 1 1 1 1]
for k,c in zip(key,cnt): print(k,c)
1 2 2 1 3 2 4 1 5 3 6 1 9 1 40 1 50 1