-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
BUG: ignore errors for invalid dates in to_datetime() with errors=coerce (#25512) #26561
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
Conversation
…as-dev#25512) parsing.try_parse_year_month_day() in _attempt_YYYYMMDD() throws not only ValueError but also OverFlowError for incorrect dates. So handling of this error was added.
Codecov Report
@@ Coverage Diff @@ ## master #26561 +/- ## ========================================== - Coverage 91.77% 91.76% -0.01% ========================================== Files 174 174 Lines 50649 50649 ========================================== - Hits 46483 46479 -4 - Misses 4166 4170 +4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@ ## master #26561 +/- ## ========================================== - Coverage 91.77% 91.77% -0.01% ========================================== Files 174 174 Lines 50649 50681 +32 ========================================== + Hits 46483 46510 +27 - Misses 4166 4171 +5
Continue to review full report at Codecov.
|
jreback left a comment
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 add a whatnew note, bug fixes, datetimes is good
| result = to_datetime(s, format='%Y%m%d', cache=cache) | ||
| assert_series_equal(result, expected) | ||
| | ||
| # GH 25512 |
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 make a new test (and _overflow) in the name
| def test_to_datetime_format_YYYYMMDD_overflow(self, cache): | ||
| # GH 25512 | ||
| # NaN before strings with invalid date values, errors=coerce | ||
| s = Series(['19801222', np.nan, '20010012', '10019999']) |
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.
Could you parameterize over these Series inputs?
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.
Is it what you meant?
Thanks!
WillAyd left a comment
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.
lgtm - nice job!
| thanks @nathalier very nice. note that this might close another existing issue or 2, though searching for issues like this are hard |
git diff upstream/master -u -- "*.py" | flake8 --diffparsing.try_parse_year_month_day() in _attempt_YYYYMMDD() throws not only ValueError but also OverFlowError for incorrect dates. So handling of this error was added.