title: multi-index pandas dataframe to a dictionary
body: <p>I have a dataframe as following:</p>
  
  <pre><code>raw_data = {'regiment': ['Nighthawks', 'Nighthawks', 'Nighthawks', 'Nighthawks', 'Dragoons', 'Dragoons', 'Dragoons', 'Dragoons', 'Scouts', 'Scouts', 'Scouts', 'Scouts'],
      'company': ['1st', '1st', '2nd', '2nd', '1st', '1st', '2nd', '2nd','1st', '1st', '2nd', '2nd'],
      'name': ['Miller', 'Jacobson', 'Ali', 'Milner', 'Cooze', 'Jacon', 'Ryaner', 'Sone', 'Sloan', 'Piger', 'Riani', 'Ali'],
      'preTestScore': [4, 24, 31, 2, 3, 4, 24, 31, 2, 3, 2, 3],
      'postTestScore': [25, 94, 57, 62, 70, 25, 94, 57, 62, 70, 62, 70]}
  
  df = pd.DataFrame(raw_data, columns = ['regiment', 'company', 'name', 'preTestScore', 'postTestScore'])
  </code></pre>
  
  <p>if I groupby by two columns and count the size,</p>
  
  <pre><code>df.groupby(['regiment','company']).size()
  </code></pre>
  
  <p>I get the following:</p>
  
  <pre><code>regiment    company
  Dragoons    1st        2
              2nd        2
  Nighthawks  1st        2
              2nd        2
  Scouts      1st        2
              2nd        2
  dtype: int64
  </code></pre>
  
  <p>What I want as an output is a dictionary as following:</p>
  
  <pre><code>{'Dragoons':{'1st':2,'2nd':2},
   'Nighthawks': {'1st':2,'2nd':2}, 
    ... }
  </code></pre>
  
  <p>I tried different methods but to no avail. Is there relatively clean way to achieve the above? </p>
  
  <p>Thank you so much in advance!!!!</p>