title: Normalize column in pandas dataframe by sum of grouped values of another column
body: <p>I'm a bit stuck on trying to normalize some entries of a column in a pandas dataframe. So I have a dataframe like this:</p>
  
  <pre><code>df = pd.DataFrame({
          'user':[0,0,1,1,1,2,2], 
          'item':['A','B', 'A', 'B','C','B','C'],
          'bought':[1,1,1,3,3,2,3]})
  df
  bought|item|user
  ----------------
  1     |A   |0
  1     |B   |0
  1     |A   |1
  3     |B   |1
  3     |C   |1
  2     |B   |2
  3     |C   |2
  </code></pre>
  
  <p>I would like to get the number of each item bought normalized by the the total bought by each user. </p>
  
  <p>In other words, for each entry of 'bought' I'd like to divide it by the sum of the total bought for that user (as another column). In this case the output I'd like is this (but the 'normalized' column doesn't have to be fractions):</p>
  
  <pre><code>bought|item|user|normalized
  --------------------------
  1     |A   |0   |1/2
  1     |B   |0   |1/2
  1     |A   |1   |1/7
  3     |B   |1   |3/7
  3     |C   |1   |3/7
  2     |B   |2   |2/5
  3     |C   |2   |3/5
  </code></pre>
  
  <p>So far I've grouped by user and gotten the sum by user:</p>
  
  <pre><code>grouped = df.groupby(by='user')
  grouped.aggregate(np.sum)
  </code></pre>
  
  <p>But at this point I'm stuck. Thanks!</p>