-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Conversation
seems fine. small comments. ping on green. |
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Green. |
@@ -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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
735e66c
to
77a5347
Compare
77a5347
to
d677f94
Compare
lgtm ping on green |
thanks |
git diff upstream/master -u -- "*.py" | flake8 --diff
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 toSeries({'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.