title: pandas groupby to nested json -- dont want calculated fields
body: <p>I'm working on a d3.js graphic.  My data is in a huge multitab .xls. I have to grab data from each tab, so I decided to dump it all in pandas and export some .json.</p>
  
  <p>original data, spread across many tabs:</p>
  
  <pre><code>demography, area, state, month, rate
  over 65,   region2, GA, May, 23
  over 65,  region2, AL, May, 25
  NaN,  random_odd_data, mistake, error
  18-65, region2, GA, 77
  18-65, region2, AL, 75
  </code></pre>
  
  <p>now, put in pandas, merged and cleaned up:</p>
  
  <pre><code>     demography area     state  month rate
  0    over 65    region2  GA     May   23
  1    over 65    region2  AL     May   25
  2    18-65      region2  GA     May   50
  3    18-65      region2  AL     May   55
  </code></pre>
  
  <p>now, group it</p>
  
  <pre><code>group = df.groupby(['state', 'demography'])
  </code></pre>
  
  <p>yields </p>
  
  <pre><code>&lt;pandas.core.groupby.DataFrameGroupBy object at 0x106939610&gt;
  </code></pre>
  
  <p>trying this:</p>
  
  <pre><code>group = df.groupby(['state', 'demography']).count()
  </code></pre>
  
  <p>yields something almost correct, except I don't want to count anything, I just want "rate"</p>
  
  <pre><code>state    demography  area   month  rate
  AL       over 65     1      1      1
           18-65       1      1      1
  GA       over 65     1      1      1
           18-65       1      1      1
  </code></pre>
  
  <p>sure enough, this only exports "1" for every value, lol:</p>
  
  <pre><code>group.reset_index().to_json("myjson2.json", orient="index")
  </code></pre>
  
  <p>dang I am almost there, how do I export it so each state is a parent? </p>
  
  <pre><code>[
      {
          "state": "Alabama",
          "over 65": 25,
          "18-65": 50
  
      },
      {
          "state": "Georgia",
          "over 65": 23,
          "18-65": 55
      }
  ]
  </code></pre>