title: Pandas: Percentage within Category
body: <p>I have a data-frame like this (except with many more rows and sizes, say):</p>
  
  <pre><code>   size amount
  1   big      1
  2   big      9
  3 small      3
  4 small      1
  </code></pre>
  
  <p>and I would like to get a data frame like this, where amountPct is amount divided by the sum of amounts with the same size. </p>
  
  <pre><code>   size amountPct
  1   big      0.10
  2   big      0.90
  3 small      0.75
  4 small      0.25
  </code></pre>
  
  <p>I can do this by reshaping the data frame, dividing through by the sum for each size, and then reshaping it back to the original shape, but is there a more elegant way of doing this?</p>
  
  <p>PS: I asked the same question for R but now I would like the answer for Pandas!</p>