title: GroupBY frequency counts JSON response - nested field
body: <p>I'm trying aggregate the response from an API call that returns a JSON object and get some frequency counts.</p>
  
  <p>I've managed to do it for one of the fields in the JSON response, but a second field that I want to try the same thing isn't working</p>
  
  <p>Both fields are called "category" but the one that isn't working is nested within "outcome_status".</p>
  
  <p>The error I get is KeyError: 'category'</p>
  
  <p>The below code uses a public API that does not require authentication, so can be tested easily.</p>
  
  <pre><code>import simplejson
  import requests
  
  #make a polygon for use in the API call
  lat_coord = 51.767538
  long_coord = -1.497488
  lat_upper = str(lat_coord + 0.02)
  lat_lower = str(lat_coord - 0.02)
  long_upper = str(long_coord + 0.02)
  long_lower = str(long_coord - 0.02)
  
  #call from the API - no authentication required
  api_call="https://data.police.uk/api/crimes-street/all-crime?poly=" + lat_lower + "," + long_upper + ":" + lat_lower  + "," + long_lower + ":" + lat_upper + "," + long_lower + ":"  + lat_upper  + "," + long_upper + "&amp;date=2017-01"
  print (api_call)
  
  request_resp=requests.get(api_call).json()
  
  import pandas as pd
  import numpy as np
  
  df_resp = pd.DataFrame(request_resp)
  
  #frequency counts for non-nested field (this works) 
  df_resp.groupby('category').context.count()
  
  #next bit tries to do the nested (this doesn't work)
  
  #tried dropping nulls
  df_outcome = df_resp['outcome_status'].dropna()
  print(df_outcome)
  
  #tried index reset
  df_outcome.reset_index()
  
  #just errors
  df_outcome.groupby('category').date.count()
  </code></pre>