This content originally appeared on DEV Community and was authored by Vicky Kumar
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'
:
user_dict
…
This content originally appeared on DEV Community and was authored by Vicky Kumar
Vicky Kumar | Sciencx (2021-06-24T09:25:18+00:00) Answer: Construct pandas DataFrame from items in nested dictionary. Retrieved from https://www.scien.cx/2021/06/24/answer-construct-pandas-dataframe-from-items-in-nested-dictionary/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.