-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: parse_dates may have columns not in dataframe #32320
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 2 commits
d24b57a
3a99b39
78ff312
007c992
7f1cd69
110f594
1536b77
6272a7d
57c114d
ee4f3fb
633e481
537f4df
22c399b
337efcd
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 |
---|---|---|
|
@@ -1516,3 +1516,33 @@ def test_hypothesis_delimited_date(date_format, dayfirst, delimiter, test_dateti | |
|
||
assert except_out_dateutil == except_in_dateutil | ||
assert result == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"names, usecols, parse_dates, missing_cols", | ||
[ | ||
(None, ["val"], ["date", "time"], "date, time"), | ||
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. add a tuple or other list-like in this test 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. When I use tuple, _validate_parse_dates_arg throws the following error.
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. Yea I guess this is only currently documented as supporting scalars, lists and dicts (not tuples) |
||
(None, ["val"], [0, "time"], "time"), | ||
(None, ["val"], [["date", "time"]], "date, time"), | ||
(None, ["val"], [[0, "time"]], "time"), | ||
(None, ["val"], {"date": [0, "time"]}, "time"), | ||
(None, ["val"], {"date": ["date", "time"]}, "date, time"), | ||
(None, ["val"], [["date", "time"], "date"], "date, time"), | ||
(["date1", "time1", "temperature"], None, ["date", "time"], "date, time"), | ||
( | ||
["date1", "time1", "temperature"], | ||
["date1", "temperature"], | ||
["date1", "time"], | ||
"time", | ||
), | ||
], | ||
) | ||
def test_missing_column(all_parsers, names, usecols, parse_dates, missing_cols): | ||
sathyz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""GH31251 column names provided in parse_dates could be missing.""" | ||
sathyz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
parser = all_parsers | ||
content = StringIO("date,time,val\n2020-01-31,04:20:32,32\n") | ||
msg = f"Missing column provided to 'parse_dates': '{missing_cols}'" | ||
with pytest.raises(ValueError, match=msg): | ||
parser.read_csv( | ||
content, sep=",", names=names, usecols=usecols, parse_dates=parse_dates, | ||
) |
Uh oh!
There was an error while loading. Please reload this page.