title: Convert pandas DataFrame to a nested dict
body: <p>I'm Looking for a generic way of turning a DataFrame to a nested dictionary</p>
  
  <p>This is a sample data frame </p>
  
  <pre><code>    name    v1  v2  v3
  0   A       A1  A11 1
  1   A       A2  A12 2
  2   B       B1  B12 3
  3   C       C1  C11 4
  4   B       B2  B21 5
  5   A       A2  A21 6
  </code></pre>
  
  <p>The number of columns may differ and so does the column names.</p>
  
  <p>like this : </p>
  
  <pre><code>{
  'A' : { 
      'A1' : { 'A11' : 1 }
      'A2' : { 'A12' : 2 , 'A21' : 6 }} , 
  'B' : { 
      'B1' : { 'B12' : 3 } } , 
  'C' : { 
      'C1' : { 'C11' : 4}}
  }
  </code></pre>
  
  <p>What is best way to achieve this ? </p>
  
  <p>closest I got was with the <code>zip</code> function but haven't managed to make it work for more then one level (two columns).</p>