-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
Added improvements in to_datetime Error reporting message #47597
Conversation
Thanks for the PR @dannyi96. Can you review the tests please? We usually test for error messages, and those tests are probably failing. Also, can you add a note to the release notes about this? Thank you! |
For |
|
sure thing @mroeschke , one quick question here -
|
I think keeping it simple with option 1 is good for now |
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.
I know you are trying to tackle 3 issues in this PR, but I would recommend splitting this PR into 3, addressing one issue per PR. It will help the review scope greatly.
sure thing @mroeschke. that would indeed be better. |
Thanks for your effort here so far @dannyi96. I'm supportive of the changes here generally. We just need to be a little mindful of exceptions in this part of the code base since there's a lot of "fall back" behavior triggered by exceptions. |
thanks @mroeschke for the guidance/support 🙂 |
This PR aims to close 3 related issues -
The exceptions from to_datetime(errors='raise') could include information about the exception #16757 ,
BUG: Confusing error message when
to_datetime
fails for times #46509 ,BUG: to_datetime ParserError on incorrect element #47495
Changes description
pandas/_libs/tslib.pyx
in_array_to_datetime_object
andarray_to_datetime
to_datetime
fails for times #46509 - added more details in OutOfBoundsDatetime exception about field and its position causing the issue inpandas/_libs/tslib.pyx
inarray_to_datetime
pandas/_libs/tslibs/parsing.pyx
to accept "now" and "today" values. These values are accepted in other parts of parsing (_parse_today_now
inpandas/_libs/tslib.pyx
) but whenpd.to_datetime
is supplied with an list having an error value(eg -pd.to_datetime(["today", "yesterday"])
), the parsing done post raised exception inparse_datetime_string
inpandas/_libs/tslibs/parsing.pyx
does not accept "now" and "today", hence the wrong element is shown in the errorExamples of changed error messages
To Do