df = pandas.DataFrame({'month': np.random.randint(0, 11, 100), 'A': np.
    random.randn(100), 'B': np.random.randn(100)})
df.join(df.groupby('month')['A'].sum(), on='month', rsuffix='_r')
Python Pandas How to assign groupby operation results back to columns in parent dataframe?