DEV Community


Answer: Construct pandas DataFrame from items in nested dictionary

Vicky Kumar
Python and C++ is my coding platform...
・1 min read

A pandas MultiIndex consists of a list of tuples. So the most natural approach would be to reshape your input dict so that its keys are tuples corresponding to the multi-index values you require. Then you can just construct your dataframe using pd.DataFrame.from_dict, using the option orient='index':



Discussion (0)