title: Python Pandas - Flatten Nested JSON
body: <p>Working with Nested JSON data that I am trying to transform to a Pandas dataframe. The <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.io.json.json_normalize.html" rel="nofollow noreferrer">json_normalize</a> function offers a way to accomplish this. </p>
  
  <pre class="lang-py prettyprint-override"><code>{'locations': [{'accuracy': 17,
                  'activity': [{'activity': [{'confidence': 100,
                                              'type': 'STILL'}],
                                'timestampMs': '1542652'}],
                  'altitude': -10,
                  'latitudeE7': 3777321,
                  'longitudeE7': -122423125,
                  'timestampMs': '1542654',
                  'verticalAccuracy': 2}]}
  </code></pre>
  
  <p>I utilized the function to normalize locations, however, the nested part 'activity' is not flat. </p>
  
  <p>Here's my attempt: </p>
  
  <pre><code>activity_data = json_normalize(d, 'locations', ['activity','type', 'confidence'], 
                                 meta_prefix='Prefix.',
                                 errors='ignore') 
  </code></pre>
  
  <p>DataFrame: </p>
  
  <pre><code>[{u'activity': [{u'confidence': 100, u'type': ...   -10.0   NaN 377777377   -1224229340 1542652023196   
  </code></pre>
  
  <p>The Activity column still has nested elements which I need unpacked in its own column. </p>
  
  <p>Any suggestions/tips would be much appreciated. </p>