-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DEPR: passing mixed offsets with utc=False into to_datetime #54014
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 1 commit
bcbe2ac
ba99e93
441e17f
5e568bd
2aa5c10
8197005
ca4b214
a0e970a
156ea8a
643d3d6
61d4deb
f2bbedf
5c4904a
f5e5e1e
88f3845
3d74972
88ed6c1
180ccce
6ecd997
dc7c54d
b5bbd2b
1220130
0549e6d
b01c3ef
04ef036
c42f143
5e5adc6
3aa091f
acee8de
b7a2207
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 |
---|---|---|
|
@@ -561,14 +561,6 @@ cpdef array_to_datetime( | |
# (with individual dateutil.tzoffsets) are returned | ||
is_same_offsets = len(out_tzoffset_vals) == 1 | ||
if not is_same_offsets: | ||
warnings.warn( | ||
"In a future version of pandas, parsing datetimes with mixed time " | ||
"zones will raise a warning unless `utc=True`. " | ||
"Please specify `utc=True to opt in to the new behaviour " | ||
"and silence this warning.", | ||
FutureWarning, | ||
stacklevel=find_stack_level(), | ||
) | ||
return _array_to_datetime_object(values, errors, dayfirst, yearfirst) | ||
else: | ||
tz_offset = out_tzoffset_vals.pop() | ||
|
@@ -628,6 +620,7 @@ cdef _array_to_datetime_object( | |
# 1) NaT or NaT-like values | ||
# 2) datetime strings, which we return as datetime.datetime | ||
# 3) special strings - "now" & "today" | ||
unique_timezones = set() | ||
for i in range(n): | ||
# Analogous to: val = values[i] | ||
val = <object>(<PyObject**>cnp.PyArray_MultiIter_DATA(mi, 1))[0] | ||
|
@@ -657,6 +650,7 @@ cdef _array_to_datetime_object( | |
tzinfo=tsobj.tzinfo, | ||
fold=tsobj.fold, | ||
) | ||
unique_timezones.add(tsobj.tzinfo) | ||
|
||
except (ValueError, OverflowError) as ex: | ||
ex.args = (f"{ex}, at position {i}", ) | ||
|
@@ -674,6 +668,15 @@ cdef _array_to_datetime_object( | |
|
||
cnp.PyArray_MultiIter_NEXT(mi) | ||
|
||
if len(unique_timezones) > 1: | ||
jbrockmendel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
warnings.warn( | ||
"In a future version of pandas, parsing datetimes with mixed time " | ||
"zones will raise a warning unless `utc=True`. " | ||
Comment on lines
+673
to
+674
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. The message here says that this will raise a warning in the future. But is that indeed the intent, or should that be "error" instead? 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. you're right, thanks - @natmokval fancy addressing this in a separate PR? 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. sure, I replaced "warning" with "error" in warning message and made a new PR |
||
"Please specify `utc=True to opt in to the new behaviour " | ||
"and silence this warning.", | ||
FutureWarning, | ||
stacklevel=find_stack_level(), | ||
) | ||
return oresult_nd, None | ||
|
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.