Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 23, 2018

Conversation

topper-123
Copy link
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
Contributor

jreback commented Feb 22, 2018

seems fine. small comments. ping on green.

@codecov
Copy link

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
Contributor Author

Green.

@jreback jreback added this to the 0.23.0 milestone Feb 22, 2018
@@ -405,8 +405,8 @@ def test_get_numeric_data(self):
result = df.get_dtype_counts()
expected = Series({'int64': 1, 'float64': 1,
datetime64name: 1, objectname: 1})
result.sort_index()
expected.sort_index()
result.sort_index(inplace=True)
Copy link
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

@@ -1362,9 +1362,9 @@ def test_constructor_with_datetimes(self):
expected['float64'] = 1
expected[floatname] = 1

result.sort_index()
result.sort_index(inplace=True)
Copy link
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
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
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