Best Way to add group totals to a dataframe in Pandas
Solution 1:
df['TotalCount'] = df.groupby('Group')['Count'].transform('sum')
Some other options are discussed here.
df['TotalCount'] = df.groupby('Group')['Count'].transform('sum')
Some other options are discussed here.