-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
Duplicate ReportDuplicate issue or pull requestDuplicate issue or pull request
Description
Code Sample
import pandas as pd
print(pd.DataFrame({0:{'B':'First row','A':'Second row'}}))
print(pd.DataFrame([{'B':'First column','A':'Second column'}]))
Results in
0
A Second row
B First row
A B
0 Second column First column
Problem description
The two constructor calls above reorder the rows or columns, respectively, alphabetically, so the row or column, respectively, indexed by 'A' always comes first.
Expected Output
The order of the dict should be preserved now that Python dictionaries are officially ordered.
Hence, the row or column, respectively, indexed by 'A' should come second.
I don't need to make an argument for this, because pandas itself has already decided so:
https://pandas.pydata.org/pandas-docs/version/0.23.0/whatsnew.html#whatsnew-0230-api-breaking-dict-insertion-order
Versions
Tested with pandas 0.24.2 and Python 3.7
Metadata
Metadata
Assignees
Labels
Duplicate ReportDuplicate issue or pull requestDuplicate issue or pull request