title: Pandas Dataframe to Nested JSON
body: <p>I am trying to convert a Pandas Dataframe to a JSON object. My Dataframe contains data in the following format: </p>
  
  <pre><code>         student      date    grade         course
  0     Student_1    2017-06-25  93          ENGLISH
  1     Student_2    2017-06-25  83          ENGLISH
  2     Student_1    2017-06-25  93          MATH
  3     Student_2    2017-06-25  83          MATH
  4     Student_1    2017-06-26  90          MATH
  5     Student_2    2017-06-26  85          MATH
  6     Student_1    2017-06-26  96          ENGLISH
  7     Student_2    2017-06-26  99          ENGLISH
  </code></pre>
  
  <p>I want to convert it to a JSON object in the following format:</p>
  
  <pre><code>[
      {'ENGLISH': [
        {
          'date' : '2017-06-25',
          'Student_1' : 93,
          'Student_2' : 83
        },
  
        {
          'date' : '2017-06-26',
          'Student_1' : 96,
          'Student_2' : 89
        }]
     },
  
      {'MATH': [
        {
          'date' : '2017-06-25',
          'Student_1' : 93,
          'Student_2' : 83
        },
  
        {
          'date' : '2017-06-26',
          'Student_1' : 90,
          'Student_2' : 85
        }]
      }
  ]
  </code></pre>
  
  <p>A simple <code>.to_json()</code> call did not do the trick for me. Is there anyway I can create the JSON object in the required format in Pandas?</p>