PANDAS Tambahkan kolom Nilai Hitungan ke DataFrame

df['Counts'] = df.groupby(['Color'])['Value'].transform('count')

# Go from this df
Color Value
Red   100
Red   150
Blue  50

# to this df
Color Value Counts
Red   100   2
Red   150   2 
Blue  50    1
Active Programmer