distinct values and counts in an array in pyhon code example
Example 1: count unique values in python
aa="XXYYYSBAA"
bb=dict(zip(list(aa),[list(aa).count(i) for i in list(aa)]))
print(bb)
# output:
# {'X': 2, 'Y': 3, 'S': 1, 'B': 1, 'A': 2}
Example 2: counting unique values python
df.loc[df['mID']=='A','hID'].agg(['nunique','count','size'])