title: Pandas dataframe to nested dictionary
body: <p>Let's say my dataframe looks like this.</p>
  
  <pre><code>date     app_id country val1 val2 val3 val4
  2016-01-01  123 US       50   70   80   90
  2016-01-02  123 US       60   80   90   100
  2016-01-03  123 US       70   88   99   11
  </code></pre>
  
  <p>I want to dump this into a nested dictionary or even a JSON object as follows:</p>
  
  <pre><code>{
     country:
     {
         app_id: 
         {
             date: [val1, val2, val3, val4]
         }
      }
  }
  </code></pre>
  
  <p>So that way if I called <code>my_dict['US'[123['2016-01-01']]]</code>, I would get to the list <code>[50,70,80,90]</code></p>
  
  <p>Is there an elegant way to go about doing this? I'm aware of Pandas's <code>to_dict()</code> function but I can't seem to get around nesting dictionaries.</p>