-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: Fix to_datetime not respecting dayfirst #58876
BUG: Fix to_datetime not respecting dayfirst #58876
Conversation
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
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.
thanks for your PR!
Are you sure that dateutil doesn't take dayfirst
into account? it's an argument that's passed in, and it seems to still be respected in cases when the dateutil path is used:
In [11]: pd.to_datetime(['foo', '10.03.2000'], dayfirst=True, errors='coerce')
<ipython-input-11-69ca28852760>:1: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.
pd.to_datetime(['foo', '10.03.2000'], dayfirst=True, errors='coerce')
Out[11]: DatetimeIndex(['NaT', '2000-03-10'], dtype='datetime64[s]', freq=None)
In [12]: pd.to_datetime(['foo', '10.03.2000'], errors='coerce')
<ipython-input-12-8697ff36715a>:1: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.
pd.to_datetime(['foo', '10.03.2000'], errors='coerce')
Out[12]: DatetimeIndex(['NaT', '2000-10-03'], dtype='datetime64[s]', freq=None)
but it's been a while since I looked at this code too closely, so I might be missing something
Ah, I guess the dateutil path was not being used here. |
The formatting makes it seem like I made a lot of changes but essentially I just added an |
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.
thanks @Aloqeely , this looks better!
the test you've added hits the conversion.pyx
code you've modified
however, I don't think it hits the line you've modified in parsing.pyx
? in which case, could you add such a test please?
The test fails if I revert the changes in pandas/pandas/tests/tools/test_to_datetime.py Lines 3044 to 3046 in 4c27530
|
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.
ah nice, so the test already covers both paths
looks good, just a merge conflict to resolve
Thanks @Aloqeely |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.