BUG: Preserve index order when constructing DataFrame from dict by bchu · Pull Request #26113 · pandas-dev/pandas (original) (raw)

The more I am looking at this the less I am thinking we can actually support this. We had a similar discussion here:

#25915 (comment)

The original issue being linked is pretty explicit about orient='index' which I think could work in and of itself since index items would always be the keys in the top level dict, but this PR is starting to stray further down into nested dicts which I don't think is generalizable.

For instance, what is the expectation if this occurs:

data = { 'A': {'bar': 0, 'foo': 1}, 'B': {'foo': 0, 'bar': 1} } pd.DataFrame(data)

Even this one modified in the PR gets a little suspect:

df.agg({'A' : ['max', 'min'], 'B' : ['min', 'sum']})