-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
to_datetime, inconsistent behavior with invalid dates. #10154
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
Comments
To show it with a little bit simpler example (as the format you show can be a bit ambiguous depending on the month/day):
So it is for the code-path with using a specified |
@vincentdavis this is pretty straightforward, just need to the catch the exception and if |
I would like to help but I am having problems getting started. How to you recommend setting up a development environment for pandas, are there docs on how to do this. What needs to be installed? |
http://pandas.pydata.org/pandas-docs/stable/contributing.html the actual code to look at is in |
Do you want a test for to_datetime() or array_strptime() my vote is to_datetime() as it is really about obeying coerce=True |
your example cases can serve as tests |
In this case I was expecting a value error |
@vincentdavis te default for |
@jorisvandenbossche
I would expect the same from this but get a ValueError.
adding format="%Y-%m-%d" should not change the output. |
@vincentdavis yes, I think you are correct. Although I don't really like this default of not raising but returning back the original string, so I more like the behaviour of when providing |
with I think it would be nice to change the default (let's make a separate issue for that though). |
closed by #10520 |
Consider Feb 29 1991 (2291991) and March 32 1991 (3321991), Both are invalid dates.
Returns a TypeError: ValueError: day is out of range for month
While
Returns NaT. Which is what I would expect.
In any case they should return the same error or value
Joris Van den Bossche pointed out on the mailing list:
"It has something to do with the number of the day, only values above 31 convert to NaT, 31 or lower raises the error (eg also 31 April raise error instead of giving NaT)"
The text was updated successfully, but these errors were encountered: