-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fixes #45506 Catch overflow error when converting to datetime #45532
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
308669b
to
dfc7033
Compare
Hello @Compro-Prasad! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2022-01-31 14:17:45 UTC |
dfc7033
to
03869c5
Compare
Could you add a unit test? Also I don't think this closes the original issue. I think in the original issue the strings should be just compared as strings not datetime-like objects. |
Yeah I was hoping the fix would result in a boolean series. import pandas as pd
data = [
{"f_0": "2015-07-01", "f_2": "08335394550"},
{"f_0": "2015-07-02", "f_2": "+49 (0) 0345 300033"},
{"f_0": "2015-07-03", "f_2": "+49(0)2598 04457"},
{"f_0": "2015-07-04", "f_2": "0741470003"},
{"f_0": "2015-07-05", "f_2": "04181 83668"},
]
dtypes = dict(f_0='datetime64[ns]', f_2='string')
df = pd.DataFrame(data=data).astype(dtypes)
df['f_0'].eq(df['f_2'])
|
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.
pls always start with a test that demonstrates the issue (from the OP)
Sure. On it.
Guessing datatypes isn't the most pleasant things to work with. For efficiency its nice to convert both into strings. But if one is already a datetime like object then its more convenient to prefer datetime over string. If that fails, string should be preferred. This case from OP is not a real scenario anyway.
That is what I get after applying the fix:
Sure thing. I am very new to pandas development. Thanks for the suggestion. I will add a test. |
03869c5
to
6742da3
Compare
Have added a test in |
7a2c829
to
5b6c6cf
Compare
4e82d1d
to
7c7286c
Compare
I found the following error from
IMO using Shall I make the changes? |
ignore as this is taken care of elsewhere |
ee0b3e2
to
9f1fb0f
Compare
89a3907
to
583d41e
Compare
583d41e
to
cdb324b
Compare
@jreback Have made the changes. |
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.
great, can you add a whatsnew entry in bug fixes for 1.5 (conversion or the datetime section is fine). and ping on green.
45eb751
to
8a12f16
Compare
@jreback Have added the whatsnew entry. |
8a12f16
to
649e559
Compare
Exception is raised when a part of the date like day, month or year is greater than 32 bit signed integer. Added tests for this issue in pandas/tests/series/methods/test_compare.py Added whatsnew entry for v1.5.0
649e559
to
80a4f36
Compare
thanks @Compro-Prasad |
Exception is raised when date part (like day, month, year) is greater than 32 bit signed integer