This is a repost of #9359 with some new fancy code that handles lots of different kinds of edge cases. Please take a look at the code:
https://gist.github.com/cloudformdesign/13278001b1a0b0cde647
Basically this allows automatic loading of nested dictionaries, whether those dictionaries are a "list of dictionaries" or a "dictionary of lists", it handles them as you would expect them to be handled by automatically creating a MultiIndex.
My hope is that the dataframe_dict
function be used instead of the standard DataFrame.from_dict
method.
This is not an edge case -- this is a use case that arrives frequently for people who use mongo or who store data in nested dictionaries.
If you agree that it is functionality worth adding, I can make the changes to pandas and make a pull request.
Comment From: jreback
well, this solution would have to be completely backwards compat, IOW. - all test must pass w/o modifcation - perf must be equal or greater than current
If you need the API then would have to be a compelling reason.
All that said If you can make it work would be gr8.
Comment From: vitiral
PR, please evaluate #9529
Comment From: mroeschke
The feature is possible with the new pd.ArrowDtype
with pyarrow.map_
as the pyarrow type so closing