title: Conditional groupby sum
body: <p>I would like to create a column that contains the sum of all amounts that occurred in a given hour. For example, if the row I am looking at has 0 under the column 0, I would like the volume column for that row to be the total volume for all amounts that occurred within that hour.</p>
  
  <p>So:</p>
  
  <pre><code>dat.groupby('Hours')['Amount'].sum()
  </code></pre>
  
  <p>by performing groupby hours and summing the amount, I get the total amount of transactions that where made in each hour. </p>
  
  <pre><code>Hours
  0     257101.87
  1     146105.69
  2     108819.17
  ....
  45    532181.83
  46    448887.69
  47    336343.60
  Name: Amount, dtype: float64
  </code></pre>
  
  <p>Problem is my database contains 1000s of rows and I can't simply create a new column with the values from the groupby, I would need a condition stipulating that if the value on the hour column is 0 then return the sum of all the amounts where the hour is 0. </p>
  
  <p>So the desired result would be something like this</p>
  
  <pre><code>Hours      Amount      Total
   0           20         100
   0           20         100
   0           60         100
   1           10          20
   1           10          20
   2           50          50
  </code></pre>
  
  <p>In this scenario I would want to create the total column and return the sum of all amounts that occurred in a given hour</p>