Skip to content

Inner dictionaries are not displaying in insertion order #25911

Closed
@boardtc

Description

@boardtc

Code Sample

newspapers = {'Jim':{'Mon':15,'Tue':17,'Wed':21,'Thu':16,'Fri':19},\
     'Tony':{'Mon':8,'Tue':15,'Wed':11,'Thu':16,'Fri':13}, \
     'Colin':{'Mon':13,'Tue':17,'Wed':19,'Thu':17,'Fri':20} \
    }
newspapers_df = pd.DataFrame(newspapers)

print(newspapers_df)

Problem description

I am using a recent download of Anaconda with Python 3.7.1 & pandas 0.23.4
The pandas doc says:

When the data is a dict, and an index is not passed, the Series index will be ordered by the dict’s insertion order

I instantiate a pandas DataFrame from a dict with no index passed, and print outputs:

Expected Output

     Jim  Tony  Colin
Mon   15     8     13
Tue   17    15     17
Wed   21    11     19
Thu   16    16     17
Fri   19    13     20

Output of `0.23.4``

      Jim  Tony  Colin
Fri   19    13     20
Mon   15     8     13
Thu   16    16     17
Tue   17    15     17
Wed   21    11     19

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDataFrameDataFrame data structure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions