Skip to content
Advertisement

Convert dictionary into dataframe (with repeated keys as rows)

I’m trying to convert the following dict: partlistzonesdef (has 50 keys) into a dataframe: Lets say we have the dict:

JavaScript

How can I convert that to a dataframe like this:

JavaScript

And so on?

Advertisement

Answer

Create a Series and transform each element of the list to a row with explode then reset_index to get expected outcome:

JavaScript

Output:

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