-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
API/ENH: tz_localize handling of nonexistent times: rename keyword + add shift option #22644
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
bf5e7bf
36d13c7
a5ea445
8753d00
e1a6c6a
a7c86c8
1884c7b
a6a05df
c4dc8aa
1bc81db
c81d58c
b2c8429
a65987d
710014c
93159e5
a0ffcdd
219256f
d435481
7c849b6
56ac4fe
b7b09bd
94a72a5
39b769e
18664d8
8852d43
38b95e9
c88b0d8
1bae682
d30f891
f337692
6a12a7e
a7b8357
7ad87ec
abad726
6be1c25
f8be4b6
c192c9f
8909f38
49f203f
01678c7
707fdde
ae27a50
85ed25e
9041ebe
a4cdac2
0a9c1db
efb382e
61c73ca
20cc925
394a0db
a5253ee
5185683
ba1bfed
8b06c96
42ae923
fe575fe
3482f92
f0e43e2
b98d4cf
e6c5b2d
83423ad
1ca0ab2
5bcc977
8cf16e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
import warnings | ||
|
||
import cython | ||
from cython import Py_ssize_t | ||
|
||
|
@@ -841,8 +839,13 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None, | |
If arraylike, must have the same length as vals | ||
nonexistent : str, bool, or arraylike | ||
If arraylike, must have the same length as vals | ||
|
||
.. versionadded:: 0.24.0 | ||
jorisvandenbossche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
errors : {"raise", "coerce"}, default "raise" | ||
|
||
.. depreciated:: 0.24.0 | ||
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. deprecated |
||
|
||
Returns | ||
------- | ||
localized : ndarray[int64_t] | ||
|
@@ -863,11 +866,6 @@ def tz_localize_to_utc(ndarray[int64_t] vals, object tz, object ambiguous=None, | |
# Vectorized version of DstTzInfo.localize | ||
assert is_coerce or is_raise | ||
|
||
if is_coerce: | ||
warnings.warn("the errors argument is deprecated, will be removed " | ||
"in a future release. Use the ambiguous or nonexistent " | ||
"argument instead.", DeprecationWarning) | ||
|
||
if tz == UTC or tz is None: | ||
return vals | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -944,6 +944,12 @@ class Timestamp(_Timestamp): | |
if ambiguous == 'infer': | ||
raise ValueError('Cannot infer offset with only one time.') | ||
|
||
if errors != 'raise': | ||
warnings.warn("The errors argument is deprecated and will be " | ||
"removed in a future release. Use the ambiguous or " | ||
"nonexistent argument instead.", FutureWarning, | ||
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. I think we can be more explicit here about how to change your code (basically the replacement that you do the lines below in code) |
||
stacklevel=2) | ||
|
||
if self.tzinfo is None: | ||
# tz naive, localize | ||
tz = maybe_get_tz(tz) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -703,6 +703,11 @@ def tz_localize(self, tz, ambiguous='raise', nonexistent='raise', | |
'2018-03-03 09:00:00'], | ||
dtype='datetime64[ns]', freq='D') | ||
""" | ||
if errors != 'raise': | ||
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. what does errors = 'coerce' actually imply in terms of nonexistent / ambiguous (see my comment above). simply translate this. Also instead of leaving the default, make |
||
warnings.warn("The errors argument is deprecated and will be " | ||
"removed in a future release. Use the ambiguous or " | ||
"nonexistent argument instead.", FutureWarning, | ||
stacklevel=2) | ||
if self.tz is not None: | ||
if tz is None: | ||
new_dates = conversion.tz_convert(self.asi8, 'UTC', self.tz) | ||
|
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.
versionadded