title: Python Pandas - Convert column to percentage on Groupby DF
body: <p>I have a dataframe that I created by a groupby:</p>
  
  <pre><code>hmdf = pd.DataFrame(hm01)
  new_hm01 = hmdf[['FinancialYear','Month','FirstReceivedDate']]
  
  hm05 = new_hm01.pivot_table(index=['FinancialYear','Month'], aggfunc='count')
  vals1 = ['April    ', 'May      ', 'June     ', 'July     ', 'August   ', 'September', 'October  ', 'November ', 'December ', 'January  ', 'February ', 'March    ']
  
  df_hm = new_hm01.groupby(['Month', 'FinancialYear']).size().unstack(fill_value=0).rename(columns=lambda x: '{}'.format(x))
  df_hml = df_hm.reindex(vals1)
  </code></pre>
  
  <p>The DF looks like this:</p>
  
  <pre><code>FinancialYear   2014/2015   2015/2016   2016/2017   2017/2018
  Month               
  April               34          24          22          20
  May                 29          26          21          25
  June                19          39          22          20
  July                23          39          18          20
  August              36          30          34           0
  September           35          23          41           0
  October             36          37          27           0
  November            38          31          30           0
  December            36          41          23           0
  January             34          30          35           0
  February            37          26          37           0
  March               36          31          33           0
  </code></pre>
  
  <p>The column names are from variables <code>(threeYr,twoYr,oneYr,Yr)</code>, and I want to convert the dataframe so that the numbers are percentages of the total for each column, but I cant get it to work.</p>
  
  <p>This is what I want:</p>
  
  <pre><code>FinancialYear       2014/2015   2015/2016   2016/2017   2017/2018
  Month               
  April                   9%          6%          6%         24%
  May                     7%          7%          6%         29%
  June                    5%         10%          6%         24%
  July                    6%         10%          5%         24%
  August                  9%          8%         10%          0%
  September               9%          6%         12%          0%
  October                 9%         10%          8%          0%
  November               10%          8%          9%          0%
  December                9%         11%          7%          0%
  January                 9%          8%         10%          0%
  February                9%          7%         11%          0%
  March                   9%          8%         10%          0%
  </code></pre>
  
  <p>Could anyone help me with doing this?</p>
  
  <p>Edit: I tried the response found at this link: <a href="https://stackoverflow.com/questions/42006346/pandas-convert-columns-to-percentages-of-the-totals">pandas convert columns to percentages of the totals</a>.....  I could not get that to work for my dataframe + it does not explain well (to me) how to make it work for any DF. The response from John Galt I believe is better than that response (my opinion).</p>