An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
June 24, 2021 09:25 am GMT
Original Link: https://dev.to/imvickykumar999/answer-construct-pandas-dataframe-from-items-in-nested-dictionary-754
Answer: Construct pandas DataFrame from items in nested dictionary
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
Original Link: https://dev.to/imvickykumar999/answer-construct-pandas-dataframe-from-items-in-nested-dictionary-754
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To