-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: read_json converted date strings with Z to UTC #26170
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
Changes from all commits
e3db59f
f3f2f7c
314aa6e
70b18ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,19 +200,27 @@ def _convert_listlike_datetimes(arg, box, format, name=None, tz=None, | |
if format is not None: | ||
raise ValueError("cannot specify both format and unit") | ||
arg = getattr(arg, 'values', arg) | ||
result = tslib.array_with_unit_to_datetime(arg, unit, | ||
errors=errors) | ||
result, tz_parsed = tslib.array_with_unit_to_datetime(arg, unit, | ||
errors=errors) | ||
if box: | ||
if errors == 'ignore': | ||
from pandas import Index | ||
result = Index(result, name=name) | ||
# GH 23758: We may still need to localize the result with tz | ||
try: | ||
return result.tz_localize(tz) | ||
except AttributeError: | ||
return result | ||
|
||
return DatetimeIndex(result, tz=tz, name=name) | ||
else: | ||
result = DatetimeIndex(result, name=name) | ||
# GH 23758: We may still need to localize the result with tz | ||
# GH 25546: Apply tz_parsed first (from arg), then tz (from caller) | ||
# result will be naive but in UTC | ||
try: | ||
result = result.tz_localize('UTC').tz_convert(tz_parsed) | ||
except AttributeError: | ||
# Regular Index from 'ignore' path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how could this ever be hit as you are constructing a DTI here? further should not all of the localization only be on this path (e.g. you must have a DTI); the way its written you could be an Index? (which is not possible) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Above there's
Where this could be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right so what hits that? meaning if it is not coerced, then we can never attempt the localization no matter what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah if it's not coerced to |
||
return result | ||
if tz is not None: | ||
if result.tz is None: | ||
result = result.tz_localize(tz) | ||
else: | ||
result = result.tz_convert(tz) | ||
return result | ||
elif getattr(arg, 'ndim', 1) > 1: | ||
raise TypeError('arg must be a string, datetime, list, tuple, ' | ||
|
Uh oh!
There was an error while loading. Please reload this page.