Working with Nested JSON data that I am trying to transform to a Pandas dataframe. The json_normalize function offers a way to accomplish this.
{'locations': [{'accuracy': 17,
'activity': [{'activity': [{'confidence': 100,
'type': 'STILL'}],
'timestampMs': '1542652'}],
'altitude': -10,
'latitudeE7': 3777321,
'longitudeE7': -122423125,
'timestampMs': '1542654',
'verticalAccuracy': 2}]}
I utilized the function to normalize locations, however, the nested part 'activity' is not flat.
Here's my attempt:
activity_data = json_normalize(d, 'locations', ['activity','type', 'confidence'],
meta_prefix='Prefix.',
errors='ignore')
DataFrame:
[{u'activity': [{u'confidence': 100, u'type': ... -10.0 NaN 377777377 -1224229340 1542652023196
The Activity column still has nested elements which I need unpacked in its own column.
Any suggestions/tips would be much appreciated.