-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: GH11616 fixes timezone selection error #11672
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: GH11616 fixes timezone selection error #11672
Conversation
@@ -1321,6 +1321,8 @@ def _possibly_downcast_to_dtype(result, dtype): | |||
try: | |||
result = result.astype(dtype) | |||
except: | |||
# convert to datetime and change timezone |
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.
this is too general. it can be a datetimelike (e.g. either M or m), and may or may not have a timezone. I think more tests are in order.
pls add a note in 0.18.0 bug fixes as well. |
pls add a test for #11682 which I believe this should fix as well |
2028eb3
to
cd40984
Compare
These errors are occurring for different reasons. First error #11616 is in _possibly_downcast_to_dtype. It is not able to retrieve correct date from int64 object. hence throwing an exception that I have fixed by checking for timezone info and then converting to correct timezone. |
@@ -1321,6 +1321,9 @@ def _possibly_downcast_to_dtype(result, dtype): | |||
try: | |||
result = result.astype(dtype) | |||
except: | |||
if dtype.tz: | |||
# convert to datetime and change timezone | |||
result = pd.to_datetime(result).tz_localize(dtype.tz) | |||
pass |
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.
don't need the pass here
looks good. pls add 2 entries in bug fixes in whatsnew for 0.18.0 |
cd40984
to
fadb72d
Compare
Done. Please review. |
@@ -105,3 +105,6 @@ Performance Improvements | |||
|
|||
Bug Fixes | |||
~~~~~~~~~ | |||
|
|||
- Bug in ``com._possibly_downcast_to_dtype`` not able to convert int64 object to correct datetime (:issue:`11616`) |
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.
no, use plain language from a user perspective; e.g. don't reference internal functions
Fixes GH11682 timzone info lost
fadb72d
to
f6daf50
Compare
merged via e838266 thanks! |
closes #11616
closes #11682