Skip to content

ENH: Let initialisation from dicts use insertion order for python >= 3.6 (part I)#19830

Merged
jreback merged 1 commit intopandas-dev:masterfrom
topper-123:py36_dict_I
Feb 23, 2018
Merged

ENH: Let initialisation from dicts use insertion order for python >= 3.6 (part I)#19830
jreback merged 1 commit intopandas-dev:masterfrom
topper-123:py36_dict_I

Conversation

@topper-123
Copy link
Copy Markdown
Contributor

This PR prepares pandas to allow initialisation using insertion order for python>=3.6. E.g. Series({'B': 1, 'A': 2}) will then retain order and not convert to Series({'A': 2, 'B': 1}).

Letting dataframe/series initialisation from dicts preserve order for python >=3.6 is a relative simple change, just change a line each in core/frame.py and core/series.py. However, this makes some 36 tests fail, as the tests have been set up to depend on conversion to alphabetical order.

This PR makes all tests in pandas/tests/frame pass both if dict initialisation uses insertion order and alphabetical order. No test functionality is changed in this PR.

After this PR I will do 1 or 2 more similar PRs, so all tests pass independent of dict initialisation rule, and then core/frame.py and core/series.py will be changed to use insertion order for python>=3.6.

@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Feb 22, 2018
@jreback
Copy link
Copy Markdown
Contributor

jreback commented Feb 22, 2018

seems fine. small comments. ping on green.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 22, 2018

Codecov Report

Merging #19830 into master will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19830      +/-   ##
==========================================
+ Coverage   91.58%   91.61%   +0.03%     
==========================================
  Files         150      150              
  Lines       48908    48892      -16     
==========================================
+ Hits        44792    44793       +1     
+ Misses       4116     4099      -17
Flag Coverage Δ
#multiple 89.99% <ø> (+0.03%) ⬆️
#single 41.79% <ø> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/core/reshape/tile.py 90.25% <0%> (-2.69%) ⬇️
pandas/util/_validators.py 96.34% <0%> (-0.47%) ⬇️
pandas/core/indexes/datetimes.py 95.32% <0%> (-0.25%) ⬇️
pandas/core/indexes/range.py 95.65% <0%> (-0.1%) ⬇️
pandas/core/indexes/timedeltas.py 90.56% <0%> (-0.07%) ⬇️
pandas/core/base.py 96.79% <0%> (-0.01%) ⬇️
pandas/core/arrays/categorical.py 94.9% <0%> (-0.01%) ⬇️
pandas/core/frame.py 97.23% <0%> (-0.01%) ⬇️
pandas/core/generic.py 95.94% <0%> (ø) ⬆️
pandas/core/indexes/base.py 96.45% <0%> (+0.03%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8768876...d677f94. Read the comment docs.

@topper-123
Copy link
Copy Markdown
Contributor Author

Green.

@jreback jreback added this to the 0.23.0 milestone Feb 22, 2018
datetime64name: 1, objectname: 1})
result.sort_index()
expected.sort_index()
result.sort_index(inplace=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you reassign, I hate inplace

expected[floatname] = 1

result.sort_index()
result.sort_index(inplace=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@jreback
Copy link
Copy Markdown
Contributor

jreback commented Feb 22, 2018

lgtm ping on green

@jreback jreback merged commit 4871b48 into pandas-dev:master Feb 23, 2018
@jreback
Copy link
Copy Markdown
Contributor

jreback commented Feb 23, 2018

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compat pandas objects compatability with Numpy or Python functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants