You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pandas 0.22 gave consistent output when creating a DataFrame passing a dictionary using any of DataFrame constructor, DataFrame.from_dict and DataFrame.from_records. pandas 0.23 changed the behaviour of creating from dictionaries to respect key ordering in Python version 3.6+ for both the DataFrame constructor and DataFrame.from_dict but not using DataFrame.from_records.
Output 0.23
Different ordering of columns depending on construction method
Pandas version : 0.23.4
DataFrame
C B A
0 3 2 1
from_dict
C B A
0 3 2 1
from_records
A B C
0 1 2 3
Output 0.22
Consistent ordering of columns (sorted keys)
Pandas version : 0.22.0
DataFrame
A B C
0 1 2 3
from_dict
A B C
0 1 2 3
from_records
A B C
0 1 2 3
@TomAugspurger My change does not change the current behaviour in that example. The code path in that case is pandas.core.frame#1315 which ultimately calls through to _list_of_dict_to_arrays.
I've pushed a test for this that shows the changed behaviour making from_records consistent with the DataFrame constructor when only a single dictionary is passed as input.
Code Sample, a copy-pastable example if possible
Problem description
pandas 0.22 gave consistent output when creating a DataFrame passing a dictionary using any of
DataFrame
constructor,DataFrame.from_dict
andDataFrame.from_records
. pandas 0.23 changed the behaviour of creating from dictionaries to respect key ordering in Python version 3.6+ for both theDataFrame
constructor andDataFrame.from_dict
but not usingDataFrame.from_records
.Output 0.23
Different ordering of columns depending on construction method
Output 0.22
Consistent ordering of columns (sorted keys)
Expected Output (my local build including #22687)
Consistent ordering of columns (dict key order respected)
The text was updated successfully, but these errors were encountered: