title: Pandas groupby sum
body: <p>I have a dataframe as follows:</p>
  
  <pre><code>ref, type, amount
  001, foo, 10
  001, foo, 5
  001, bar, 50
  001, bar, 5
  001, test, 100
  001, test, 90
  002, foo, 20
  002, foo, 35
  002, bar, 75
  002, bar, 80
  002, test, 150
  002, test, 110
  </code></pre>
  
  <p>This is what I'm trying to get:</p>
  
  <pre><code>ref, type, amount, foo, bar, test
  001, foo, 10, 15, 55, 190
  001, foo, 5, 15, 55, 190
  001, bar, 50, 15, 55, 190
  001, bar, 5, 15, 55, 190
  001, test, 100, 15, 55, 190
  001, test, 90, 15, 55, 190
  002, foo, 20, 55, 155, 260
  002, foo, 35, 55, 155, 260
  002, bar, 75, 55, 155, 260
  002, bar, 80, 55, 155, 260
  002, test, 150, 55, 155, 260
  002, test, 110, 55, 155, 260
  </code></pre>
  
  <p>So I have this:</p>
  
  <pre><code>df.groupby('ref')['amount'].transform(sum)
  </code></pre>
  
  <p>But how can I filter it such that the above only applies to rows where <code>type=foo</code> or <code>bar</code> or <code>test</code>?</p>