title: add new column and calculate ratio
body: <p>I am learning pandas and I want to create a new colum to my data ( I am using the national names data ).</p>
  
  <p>I am just using 1880 and 1881 years.</p>
  
  <pre><code>          name sex  births  year
  0        Mary   F    7065  1880
  1        Anna   F    2604  1880
  2        Emma   F    2003  1880
  3   Elizabeth   F    1939  1880
  4      Worthy   M       5  1880
  5      Wright   M       5  1880
  6        York   M       5  1880
  7   Zachariah   M       5  1880
  8        Mary   F    6919  1881
  9        Anna   F    2698  1881
  10       Emma   F    2034  1881
  11  Elizabeth   F    1852  1881
  12     Wilton   M       5  1881
  13       Wing   M       5  1881
  14       Wood   M       5  1881
  15     Wright   M       5  1881
  </code></pre>
  
  <p>I am creating the total births data:</p>
  
  <pre><code>total_births = names.pivot_table('births', index='year', columns='sex', aggfunc=sum)
  </code></pre>
  
  <p>which gives:</p>
  
  <pre><code>sex       F   M
  year           
  1880  13611  20
  1881  13503  20
  </code></pre>
  
  <p>Now, I want to create another column in the data where I will put the ratio of births per year to the total births per year.</p>
  
  <p>For example:</p>
  
  <pre><code>name  sex births     year ratio
  Mary   F   7065      1880  7065/13611
  Wilton M     5       1881   5/13503
  </code></pre>
  
  <p>I am trying:</p>
  
  <pre><code>new = (names.groupby(['year', 'sex'])).assign(ratio= (names.groupby(['year','sex'])).names['births'] / total_births )
  </code></pre>
  
  <p>which gives:</p>
  
  <pre><code>AttributeError: Cannot access callable attribute 'assign' of 'DataFrameGroupBy' objects, try using the 'apply' method
  </code></pre>
  
  <p>OR </p>
  
  <p>I tried to break :</p>
  
  <pre><code>ratio = names.groupby(['year','sex'])
  ratio1 = ratio.loc[:,'births']
  </code></pre>
  
  <p>but it gives:</p>
  
  <pre><code>AttributeError: Cannot access callable attribute 'loc' of 'DataFrameGroupBy' objects, try using the 'apply' method
  </code></pre>