pandas count values in category of column based on another column code example
Example: pd count how many item occurs in another column
df['Counts'] = df.groupby(['Color'])['Value'].transform('count')
df['Counts'] = df.groupby(['Color'])['Value'].transform('count')