Skip to content

Tag: dictionary

Convert nested dictionary to pandas dataframe

I have a nested dictionary as below: I need to convert it into a dataframe like below I have tired the following code from this answer I am getting the dataframe like below This is the closest I got to the desired output. What changes do I need to make to the code to get the desired dataframe? Answer Change

Sorting list based on dictionary keys in python

Is there a short way to sort a list based on the order of another dictionary keys? suppose I have: I want to sort the list to be [‘a’,’b’,’c’] based on the order of dic keys. Answer You can create a lookup of keys versus their insertion order in dic. To do so you can write:…