title: Percentage calculation from pivot table pandas
body: <p>I have a set of data which I have already imported from excel xlsx file. After that I determine to find out the percentage of the total profit from each of the customer segment. I manage to use the pivot_table to summarize the the total profit of each customer segment. However, I also would like to know the percentage. How do I do that?</p>
  
  <p><strong>Pivot_table</strong></p>
  
  <pre><code> profit = df.pivot_table(index = ['Customer Segment'], values = ['Profit'], aggfunc=sum)
  </code></pre>
  
  <p><strong>Result</strong> So far</p>
  
  <pre><code>Customer Segment      Profit
      A                    a
      B                    b
      C                    c
      D                    d
  </code></pre>
  
  <p>Maybe adding the percentage column to the pivot table would be an ideal way. But how can I do that?</p>