-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
ENH: tz_localize(None) allows to reset tz #7852
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
@@ -1421,6 +1421,17 @@ to determine the right offset. | |||
rng_hourly_eastern = rng_hourly.tz_localize('US/Eastern', infer_dst=True) | |||
rng_hourly_eastern.values | |||
|
|||
|
|||
To remove timezone from tz-aware ``DatetimeIndex``, use ``tz_localize(None)`` or ``tz_convert(None)``. ``tz_localize(None)`` will remove timezone holding local time representations. ``tz_convert(None)`` will remove timezone holding UTC time. |
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.
so trying tz_convert(None)
on a non-UTC does what? (why is this a special case)
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.
tz_convert(None)
removes timezone, returning an UTC time (see above example). This behavior is NOT changed by this PR, but not documented anywhere.
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.
ok, maybe let's just document that (in the same section you just fixed, and the doc-strings as well).
thanks!
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.
Sure, modified doc-strings also.
@@ -824,6 +824,24 @@ def test_tz_localize_naive(self): | |||
|
|||
self.assertTrue(conv.equals(exp)) | |||
|
|||
def test_tz_localize_roundtrip(self): |
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.
can you test tz_convert
here as well?
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.
Added tests for DatetimeIndex
and Timestamp
.
|
|
@jreback thanks! Just like I understood. :) |
This also closes #3653 |
@sinhrks pls rebase and ping when green good 2 go |
@jreback rebased, and now green |
ENH: tz_localize(None) allows to reset tz
thanks @sinhrks |
Closes #7812. Allow
tz_localize(None)
for tz-awareTimestamp
andDatetimeIndex
to reset tz.CC @rockg, @nehalecky