Skip to content
Advertisement

Converting a Dictionary to DataFrame in Python

I have a dictionary of a static structure:

JavaScript

I will need to record data a few extra keys deep to the same depth, so somewhat uniform.

Example Dictionary:

JavaScript

I want a DataFrame of this structure:

JavaScript

Example Desired DataFrame:

JavaScript

Where all Child Values are either a list object of strings or a string object.


From researching I found pandas.DataFrame.from_dict(). However neither orient values help in my case. As it is intended for flat dictionaries.

I genuinely haven’t a clue on how to approach this. What a simple libraries may be needed etc.

Please let me know if there are further details/ nuances I could clarify.

Advertisement

Answer

Use:

JavaScript

Output

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement