-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Let initialisation from dicts use insertion order for python >= 3.6 (part III) #19884
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
from pandas._libs import lib | ||
from pandas._libs.tslib import iNaT | ||
|
||
from pandas.compat import lrange, range, zip, long | ||
from pandas.compat import lrange, range, zip, long, PY36 | ||
from pandas.util.testing import assert_series_equal | ||
import pandas.util.testing as tm | ||
|
||
|
@@ -811,6 +811,18 @@ def test_constructor_dict(self): | |
expected.iloc[1] = 1 | ||
assert_series_equal(result, expected) | ||
|
||
def test_constructor_dict_order(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe could decorate tests like this one with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pandas has clearly defined ordering for python < 3.6 also (sort by values). So it's nneeded to test this distinction and not use a skipif, IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @topper-123 let's go ahead and make 2 different tests here, 1 for >= 3.6 and one for less, they should skip on the alternative, same for the tests in frame. |
||
# GH19018 | ||
# initialization ordering: by insertion order if python>= 3.6, else | ||
# order by value | ||
d = {'b': 1, 'a': 0, 'c': 2} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add ones for SparseSeries/DataFrame |
||
result = Series(d) | ||
if PY36: | ||
expected = Series([1, 0, 2], index=list('bac')) | ||
else: | ||
expected = Series([0, 1, 2], index=list('abc')) | ||
tm.assert_series_equal(result, expected) | ||
|
||
@pytest.mark.parametrize("value", [2, np.nan, None, float('nan')]) | ||
def test_constructor_dict_nan_key(self, value): | ||
# GH 18480 | ||
|
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 move this note a bit below? It seems strange to start this "from dict" section with a note without first explaining what it actually is.
So I would give an example first, and only afterwards noting that the output depends on the python version