title: Getting percent of total from subtotals in pandas pivot table
body: <p>I have the following dataframe</p>
  
  <pre><code>from io import StringIO
  incsv = StringIO("""Date,State,City,Tools,Size,y
  20130320,AZ,Phoenix,A,4,1000
  20130320,AZ,Tempe,B,4,1100
  20130320,NY,NYC,C,1,900
  20130320,NY,NYC,C,2,1300
  20130320,NY,Albany,D,1,800
  20130320,AZ,Phoenix,E,1,800
  20130320,AZ,Phoenix,F,4,800
  """)
  
  df = pd.read_csv(incsv, index_col=['Date'], parse_dates=True)
  
  
  df
            State City  Tools Size y
  Date                    
  2013-03-20  AZ  Phoenix A   4   1000
  2013-03-20  AZ  Tempe   B   4   1100
  2013-03-20  NY  NYC     C   1   900
  2013-03-20  NY  NYC     C   2   1300
  2013-03-20  NY  Albany  D   1   800
  2013-03-20  AZ  Phoenix E   1   800
  2013-03-20  AZ  Phoenix F   4   800
  </code></pre>
  
  <p>I'm attempting to calculate what % of the State/City subtotal each size of tool makes up. My next step is:</p>
  
  <pre><code>dftest=pd.pivot_table(df,index=['State'],columns=['City','Size'],values="y",aggfunc='count',margins=True)
  test=dftest.stack('City').stack('Size')
  test
  
  
  State  City     Size
  AZ     All              4.0
         Phoenix  1       1.0
                  4       2.0
         Tempe    4       1.0
  NY     Albany   1       1.0
         All              3.0
         NYC      1       1.0
                  2       1.0
  All    Albany   1       1.0
         All              7.0
         NYC      1       1.0
                  2       1.0
         Phoenix  1       1.0
                  4       2.0
         Tempe    4       1.0
  dtype: float64
  </code></pre>
  
  <p>I want my output to be</p>
  
  <pre><code>State  City     Size    Count PCT
  AZ     All              4.0   1
         Phoenix  1       1.0   .25
                  4       2.0   .5
         Tempe    4       1.0   .25
  NY     All              3.0   1
         Albany   1       1.0   .333   
         NYC      1       1.0   .333
                  2       1.0   .333
  </code></pre>
  
  <p>I was thinking about trying to iterate over the rows, find the "All"s and iterate again to create a series with the results but there has got to be a much less hacky/more performant way to accomplish this. Thanks!</p>