title: Want to calculate cumulative sum and % across hierarchical data in pandas/python
body: <p>I am trying to calculate cumulative sum and % for data in which a parent/child relationship exists, but want the cumulative sum and cum $ to be the same for all children of a given parent.</p>
  <p>Suppose the following table</p>
  <pre><code>import pandas as pd
  imp = [{'Parent':'A', 'Child':'B', 'Value': 5}
      , {'Parent':'C', 'Child':'D', 'Value': 4}
      , {'Parent':'C', 'Child':'E', 'Value': 7}
      , {'Parent':'F', 'Child':'G', 'Value': 6}
      ]
  df=pd.DataFrame(imp)
  print(df)
  </code></pre>
  <p>The resulting DataFrame:</p>
  <pre><code>Parent  Child   Value
  A       B       5
  C       D       4
  C       E       7
  F       G       6
  </code></pre>
  <p>I want to calculate the cumulative sum and % such that I would get the following:</p>
  <pre><code>Parent  Child   Value   CumSum  cumPct
  C       D       4       11      0.5
  C       E       7       11      0.5
  F       G       6       17      0.772727273
  A       B       5       22      1
  </code></pre>
  <p>I know how to normally calculate cumulative sum, but the method I am familar with doesn't work on this type of parent/child structure and will give me incorrect values.</p>
  <p>Appreciate any help you can provide.</p>