-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG/ENH: to_datetime dayfirst ought to be strict #3341
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
Another usecase, is if you call to_datetime (without setting dayfirst) on a list of british date-strings, atm it parses without error but does so "incorrectly" (using a mixture of dayfirst and not, depending). Which is confusing. |
I'm shocked that dateutil does that. |
cc @jreback. |
I think we ought to drop this parameter in favor of just using until/unless we actually do more date parsing internally thoughts? |
but but but dayfirst is the best argument ever, it's very very useful for munging (it's great if you don't know the format or worse the format is mixed (!)). It being not strict is sad, but not having it at all would be much worse. please please can we keep it! I've looked before where in their code it's not being strict, but it's pretty messy and not sure how actively maintained it is... I'm sure @wesm suggested another (C?) library fairly recently but can't find the issue. |
how about a big warning in the docstring/docs? that you really ought to specify format instead? I see the warning you have, but EVEN bigger ? (and then in docstrings too), http://pandas.pydata.org/pandas-docs/dev/timeseries.html#converting-to-timestamps |
+1 on that, definitely users should know what they are letting themselves in for. |
alright...so let's just make this a doc enhancement for now? |
How's about (pr coming):
|
Switching from #11725, where this happened, e.g. daysfirst=False would parse month as days
right now, the doc only describes the problem for the other way:
As dayfirst is False, this makes no mention that the other way can also happen |
@JanSchulz Indeed .. Maybe also worth mentioning that if you want strict behaviour, you can use |
I opened an issue for this at the dateutil tracker, as I couldn't find one: dateutil/dateutil#214 |
Not a pandas bug and documented accordingly |
This is one that we need to bug dateutil about. (Or offer a PR upstream).
Pls consider reopening.
…On Fri, Jul 6, 2018 at 5:19 PM William Ayd ***@***.***> wrote:
Not a pandas bug and documented accordingly
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3341 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHtGeGhE01ZjGL7gUpzJNp9cnjr9uqrCks5uD-KKgaJpZM4Ak1oK>
.
|
@jbrockmendel I closed because there's nothing technically to be done on the pandas side and this is arguably duplicative of #12585. Feel free to reopen if you think it's this issue in particular adds value to tracking |
xref #12585
I think this ought to raise a ValueErrror:
This means if my data is bad (i.e. somehow I have a mixture of american and british string-dates), I won't be told there was an issue when parsing! I can't think of a usecase where this kind of precedence would be appropriate, and it means you'll end up with incorrect dates.
The precedence behaviour appears to be a feature from
dateutil
(whichtslib.array_to_datetime
calls):It should raising like this:
... :(
The text was updated successfully, but these errors were encountered: