title: Python group by one column and calculate percentage of another column
body: <p>I have a dataframe as follows:</p>
  
  <pre><code>    Frame   SizeOfExposure
  0    1         5
  1    1         5
  2    2         7
  3    3         2
  4    3         8
  </code></pre>
  
  <p>I am trying to calculate the percentage of <code>SizeOfExposure</code> for each row group by <code>Frame</code> number.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>df.groupby("Frame")["SizeOfExposure"].sum()
  </code></pre>
  
  <p>This prints the sum of SizeOfExposure for each frame.  However, when I tried</p>
  
  <pre><code>df['SizeOfExpPerc']=df["SizeOfExposure"]/df.groupby("Frame")["SizeOfExposure"].sum()
  </code></pre>
  
  <p>I am getting 'Nan' filled for most rows. How do I calculate?  The desired output is</p>
  
  <pre><code>    Frame   SizeOfExposure  SizeOfExpPerc
  0    1         5                  0.5
  1    1         5                  0.5
  2    2         7                  1.0
  3    3         2                  0.2
  4    3         8                  0.8
  </code></pre>