pd count how many item occurs in another column
df['Counts'] = df.groupby(['Color'])['Value'].transform('count')
Are there any code examples left?
New code examples in category Python
df['Counts'] = df.groupby(['Color'])['Value'].transform('count')