title: Ordering hierarchical data in a pivot-like way
body: <p>I have a hierarchical dataset which needs to be presented in a certain way. Items of the same hierarchy paths needs to be presented in successive order. Further parents should be listed above their children.<br />
  Appreciate any guidance to achieve the same..</p>
  <p>Thank You</p>
  <p>** sample dataset **</p>
  <pre><code>level   Parent  Child
  0   z   z
  1   z   o
  1   z   p
  2   p   t
  2   p   q
  2   o   r
  </code></pre>
  <p>** what i tried **</p>
  <pre><code>df = pd.read_clipboard(sep='\t')
  df1=df.pivot(columns='level',values='Child')
  df1.fillna('-',inplace=True)
  df1
  </code></pre>
  <p>** my result **</p>
  <pre><code>level   0   1   2
  0   z   -   -
  1   -   o   -
  2   -   p   -
  3   -   -   t
  4   -   -   q
  5   -   -   r
  </code></pre>
  <p>** desired result **</p>
  <pre><code>level   0   1   2
  0   z   -   -
  1   -   o   -
  2   -   -   r
  3   -   p   -
  4   -   -   t
  5   -   -   q
  </code></pre>