title: Using Pandas to map results of a groupby.sum() to another dataframe?
body: <p>I have two dataframes - one which is a micro level containing all line items purchased across all transactions (DF1). The other dataframe will be built, with the intention to be a higher level aggregation that summarizes the revenue generated per transaction, essentially summing up all line items for each transaction (DF2).</p>
  
  <pre><code>df1
  Out[df1]:
     transaction_id item_id amount
  0  AJGDO-12304     120     $120
  1  AJGDO-12304     40      $10
  2  AJGDO-12304     01      $10
  3  ODSKF-99130     120     $120
  4  ODSKF-99130     44      $30
  5  ODSKF-99130     03      $50
  
  
  df2
  Out[df2]
      transaction_id    location_id      customer_id   revenue(THIS WILL BE THE ADDED COLUMN!) 
      0  AJGDO-12304          2131234       1234        $140
      1  ODSKF-99130          213124        1345        $200
  </code></pre>
  
  <p>How would I go about linking the output of a groupby.sum() and assigning it to df2? The revenue column will essentially be the revenue aggregation of df1['transaction_id'] and I want to link it to df2['transaction_id']</p>
  
  <p>Here is what I currently have tried but am struggling with putting together,</p>
  
  <pre><code>results = df1.groupby('transaction_id')['amount'].sum()
  df2['revenue'] = df2['transaction_id'].merge(results,how='left').value
  </code></pre>