I have a list of nested dictionaries in python. I tried to convert it into a dataframe using:
data=pd.DataFrame(list_of_dicts)
This converts most of the dicts into columns. However there is still the first column which consists of another list of dicts. Data looks like this:
FIS mid LI DE PBT
4182 L234 L3133 2020-02-13T09:50:53Z
In the FIS
column are still dictionaries, column first row of FIS
looks like this:
[{'FI': [{'TMC': {'PC': 6671, 'DE': 'Pohlheim-Dorf-Güll', 'QD': '+', 'LE': 0.04984}, 'SHP': [], 'CF': [{'TY': 'TR', 'SP': 30.0, 'SU': 30.0, 'FF': 30.0, 'JF': 0.0, 'CN': 0.7}]}
I tried to applied the method described above again on the FIS
column. But this doesn't write the dicts in new columns.
So my question is: How can I convert this list of dicts to a dataframe?
I extracted the data from the here api ( https://developer.here.com/documentation/traffic/dev_guide/topics/examples.html )
Thank you in advance!
It works
list_of_dicts = [{"qwerty":[1,2,3]}, {"lol":["l","o","l"]}]
df = pd.concat([pd.DataFrame(e) for e in list_of_dicts], axis=1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.