'Parsing a a list of nested dicts in Python
i m trying to parse this json string that looks like this. i tried pd.Dataframe(PayloadData['gsmRegistrationInfo'] but i got this error "list indices must be integers or slices, not str"
[{'gsmRegistrationInfo': [{'timestamp': {'secondsSince20000101': 695570408},
'countryAndOperatorCode': 310410,
'cellNumber': 170003217,
'locationAreaCode': 35634,
'networkType': 4,
'registered': 1}]
Solution 1:[1]
enter code here`from collections import defaultdict from collections import ChainMap
multiDct_to_single=[]
for i in range(len(df['gsmRegistrationInfo'])):
qq=dict(ChainMap(*df['gsmRegistrationInfo'][i][::-1])) # notice the star!
multiDct_to_single.append(qq)
data = pd.DataFrame(multiDct_to_single).head()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vanetoj |
