-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
DEPR: Deprecate from_items #18529
Merged
Merged
DEPR: Deprecate from_items #18529
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
14b37f1
DEPR: Deprecate from_items
reidy-p b01cdf8
fixing some over-indentation
reidy-p 1ff77e2
Use OrderedDict instead of dict in io/stata.py
reidy-p 4b986b3
replace another dict with OrderedDict
reidy-p c25f541
recommend from_dict(dict()) and from_dict(OrderedDict())
reidy-p 1838f65
change DEPRECATED and remove from_items from some constructor tests
reidy-p File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
from distutils.version import LooseVersion | ||
from functools import partial | ||
from warnings import catch_warnings | ||
from collections import OrderedDict | ||
|
||
import numpy as np | ||
import pytest | ||
|
@@ -315,7 +316,7 @@ def test_excel_table(self): | |
|
||
def test_reader_special_dtypes(self): | ||
|
||
expected = DataFrame.from_items([ | ||
expected = DataFrame.from_dict(OrderedDict([ | ||
("IntCol", [1, 2, -3, 4, 0]), | ||
("FloatCol", [1.25, 2.25, 1.83, 1.92, 0.0000000005]), | ||
("BoolCol", [True, False, True, True, False]), | ||
|
@@ -325,8 +326,7 @@ def test_reader_special_dtypes(self): | |
("DateCol", [datetime(2013, 10, 30), datetime(2013, 10, 31), | ||
datetime(1905, 1, 1), datetime(2013, 12, 14), | ||
datetime(2015, 3, 14)]) | ||
]) | ||
|
||
])) | ||
basename = 'test_types' | ||
|
||
# should read in correctly and infer types | ||
|
@@ -363,12 +363,12 @@ def test_reader_converters(self): | |
|
||
basename = 'test_converters' | ||
|
||
expected = DataFrame.from_items([ | ||
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. feel free to change some / most constructions with from items entirely (rather than catch the deprecation warning) |
||
expected = DataFrame.from_dict(OrderedDict([ | ||
("IntCol", [1, 2, -3, -1000, 0]), | ||
("FloatCol", [12.5, np.nan, 18.3, 19.2, 0.000000005]), | ||
("BoolCol", ['Found', 'Found', 'Found', 'Not found', 'Found']), | ||
("StrCol", ['1', np.nan, '3', '4', '5']), | ||
]) | ||
])) | ||
|
||
converters = {'IntCol': lambda x: int(x) if x != '' else -1000, | ||
'FloatCol': lambda x: 10 * x if x else np.nan, | ||
|
@@ -718,32 +718,30 @@ def test_reader_seconds(self): | |
|
||
if LooseVersion(xlrd.__VERSION__) >= LooseVersion("0.9.3"): | ||
# Xlrd >= 0.9.3 can handle Excel milliseconds. | ||
expected = DataFrame.from_items([("Time", | ||
[time(1, 2, 3), | ||
time(2, 45, 56, 100000), | ||
time(4, 29, 49, 200000), | ||
time(6, 13, 42, 300000), | ||
time(7, 57, 35, 400000), | ||
time(9, 41, 28, 500000), | ||
time(11, 25, 21, 600000), | ||
time(13, 9, 14, 700000), | ||
time(14, 53, 7, 800000), | ||
time(16, 37, 0, 900000), | ||
time(18, 20, 54)])]) | ||
expected = DataFrame.from_dict({"Time": [time(1, 2, 3), | ||
time(2, 45, 56, 100000), | ||
time(4, 29, 49, 200000), | ||
time(6, 13, 42, 300000), | ||
time(7, 57, 35, 400000), | ||
time(9, 41, 28, 500000), | ||
time(11, 25, 21, 600000), | ||
time(13, 9, 14, 700000), | ||
time(14, 53, 7, 800000), | ||
time(16, 37, 0, 900000), | ||
time(18, 20, 54)]}) | ||
else: | ||
# Xlrd < 0.9.3 rounds Excel milliseconds. | ||
expected = DataFrame.from_items([("Time", | ||
[time(1, 2, 3), | ||
time(2, 45, 56), | ||
time(4, 29, 49), | ||
time(6, 13, 42), | ||
time(7, 57, 35), | ||
time(9, 41, 29), | ||
time(11, 25, 22), | ||
time(13, 9, 15), | ||
time(14, 53, 8), | ||
time(16, 37, 1), | ||
time(18, 20, 54)])]) | ||
expected = DataFrame.from_dict({"Time": [time(1, 2, 3), | ||
time(2, 45, 56), | ||
time(4, 29, 49), | ||
time(6, 13, 42), | ||
time(7, 57, 35), | ||
time(9, 41, 29), | ||
time(11, 25, 22), | ||
time(13, 9, 15), | ||
time(14, 53, 8), | ||
time(16, 37, 1), | ||
time(18, 20, 54)]}) | ||
|
||
actual = self.get_exceldf('times_1900', 'Sheet1') | ||
tm.assert_frame_equal(actual, expected) | ||
|
@@ -1988,7 +1986,7 @@ def test_datetimes(self): | |
datetime(2013, 1, 13, 18, 20, 52)] | ||
|
||
with ensure_clean(self.ext) as path: | ||
write_frame = DataFrame.from_items([('A', datetimes)]) | ||
write_frame = DataFrame({'A': datetimes}) | ||
write_frame.to_excel(path, 'Sheet1') | ||
read_frame = read_excel(path, 'Sheet1', header=0) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It seems that some of the dataframe constructors don't allow duplicated columns while others do so I had to change the
from_items
in this test tofrom_records
andfrom_dict(OrderedDict())
to get the test passing. But I'm not sure if it still tests for the original issue correctly (#2079)All of the other tests in this file using
from_items
are directly testingfrom_items
so I left the check for the deprecation warning rather than trying to replacefrom_items
with a different constructor.