title: How do I create a new column from the output of pandas groupby().sum()?
body: <p>Trying to create a new column from the <code>groupby</code> calculation. In the code below, I get the correct calculated values for each date (see group below) but when I try to create a new column (<code>df['Data4']</code>) with it I get NaN. So I am trying to create a new column in the dataframe with the sum of <code>Data3</code> for the all dates and apply that to each date row. For example, 2015-05-08 is in 2 rows (total is 50+5 = 55) and in this new column I would like to have 55 in both of the rows. </p>
  
  <pre><code>import pandas as pd
  import numpy as np
  from pandas import DataFrame
  
  df = pd.DataFrame({
      'Date' : ['2015-05-08', '2015-05-07', '2015-05-06', '2015-05-05', '2015-05-08', '2015-05-07', '2015-05-06', '2015-05-05'], 
      'Sym'  : ['aapl', 'aapl', 'aapl', 'aapl', 'aaww', 'aaww', 'aaww', 'aaww'], 
      'Data2': [11, 8, 10, 15, 110, 60, 100, 40],
      'Data3': [5, 8, 6, 1, 50, 100, 60, 120]
  })
  
  group = df['Data3'].groupby(df['Date']).sum()
  
  df['Data4'] = group
  </code></pre>