title: ValueError: No axis named "type" for object type <class 'pandas.core.frame.DataFrame
body: <p>This is my data frame <code>df</code> received after some preprocessing:</p>
  
  <pre><code>    name    type    range   time                number
  0   XXXX    11111   1-120   [1-120, 261.05]     [1-120, 23229]
  1   XXXX    11111   121-240 [121-240, 277.79]   [121-240, 6382]
  2   XXXX    11111   241-360 [241-360, 269.64]   [241-360, 2769]
  3   XXXX    11111   361-480 [361-480, 279.09]   [361-480, 1331]
  </code></pre>
  
  <p>I want to transform it into the following json string:</p>
  
  <pre><code>[{"name":"XXXX","type":11111,"time":[["1-120",261.05],["121-240",277.79],["241-360",269.64],["361-480",279.09]],"number":[["1-120",23229],["121-240",6382],["241-360",2769],["361-480",1331]]
  </code></pre>
  
  <p>If I do it this way, I get an error <code>ValueError: No axis named "type" for object type &lt;class 'pandas.core.frame.DataFrame'&gt;</code>:</p>
  
  <pre><code>jsonresult = df.groupby('name','type')['time','number'].agg(lambda x : x.tolist()).reset_index().to_json(orient='records')
  jsonresult
  </code></pre>
  
  <p>It only works if I do <code>df.groupby('name')</code> or <code>df.groupby('type')</code>.</p>