I am trying to parse a JSON string to its lowest granularity to a panda dataframe.
Attempts
First I tried read_json:
jsonData = pd.read_json(apiRequest)
But a large chunk of the data is still nested under networkRank.
Then I tried json_normalize, but this time I am missing the data one level higher such as latitude and longitude.
result = json_normalize(json_data['networkRank'])
I also tried to parse "into" the nested structure and construct the data frame from scratch, but this code results in error:
result_nested = json_normalize(json_data, 'networkRank', ['longitude', 'latitude', ['networkRank', 'type3G', 'downloadSpeed']])
Goal
To parse the JSON data into a flat table with all fields, which means latitude, longitude and distance data appended to each row of data in figure 2.
JSON String
{'apiVersion': '2',
'distance': 10,
'latitude': '-6.162959',
'longitude': '35.751607',
'networkRank': [{'networkId': '6402',
'networkName': 'Vodacom',
'type3G': {'averageRssiAsu': '9.5429091136',
'averageRssiDb': '-69.5664329624972',
'downloadSpeed': '1508.1304',
'networkId': '6402',
'networkName': 'Vodacom',
'networkType': '3',
'pingTime': '320.9600',
'reliability': '0.804236452826138',
'sampleSizeRSSI': '948',
'sampleSizeSpeed': '29',
'uploadSpeed': '893.7692'}},
{'networkId': '6400',
'networkName': 'tiGO',
'type3G': {'averageRssiAsu': '15.3537142857',
'averageRssiDb': '-61.4563389583101',
'downloadSpeed': '516.0000',
'networkId': '6400',
'networkName': 'tiGO',
'networkType': '3',
'pingTime': '259.0000',
'reliability': '0.911904765537807',
'sampleSizeRSSI': '935',
'sampleSizeSpeed': '21',
'uploadSpeed': '320.4211'}},
{'networkId': '6403',
'networkName': 'Airtel',
'type3G': {'averageRssiAsu': '13.2729999375',
'averageRssiDb': '-58.1521092977699',
'downloadSpeed': '1080.2500',
'networkId': '6403',
'networkName': 'Airtel',
'networkType': '3',
'pingTime': '194.5556',
'reliability': '0.554680264185345',
'sampleSizeRSSI': '587',
'sampleSizeSpeed': '21',
'uploadSpeed': '572.1579'}}],
'network_type': None,
'perMinuteCurrent': 0,
'perMinuteLimit': 10,
'perMonthCurrent': 0,
'perMonthLimit': 2000}

