-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: read_column did not preserve UTC tzinfo #7790
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
@@ -3440,6 +3442,20 @@ def read_column(self, column, where=None, start=None, stop=None, **kwargs): | |||
# column must be an indexable or a data column | |||
c = getattr(self.table.cols, column) | |||
a.set_info(self.info) | |||
|
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.
better to refactor the tz handling here: https://github.com/pydata/pandas/blob/master/pandas/io/pytables.py#L1467
then I think you can directly reuse it
Hmm, I'm not quite sure that will work. |
that's not what I mean, re-factor it out as a function which you can call from both places, rather than duplicated the code |
You mean something like the following that can be called in convert and when returning the series (with preserve_UTC = True)? def _set_tz(values, tz, preserve_UTC=False):
if tz is not None and isinstance(values, Index):
tz = _ensure_decoded(tz)
if values.tz is None:
values = values.tz_localize('UTC').tz_convert(tz)
if preserve_UTC:
if tz == pytz.utc:
values = list(values)
return values |
yep though I think you can simply do |
cc @dbew |
You can't do |
@alorenzo175 ok, gr8! hmm maybe should document that somewhere ..... |
That looks good to me and the tests are sensible. |
@alorenzo175 this look good. just need release note in v0.15.0 (reference original issue in bug fix section). and I think good to go |
@jreback should be good to go now |
perfect, now just squash to a snigle commit and then I can merge, see here: https://github.com/pydata/pandas/wiki/Using-Git |
squashed |
BUG: read_column did not preserve UTC tzinfo
@alorenzo175 thanks for the fix! |
BUG: Fixes #7777, HDFStore.read_column did not preserve timezone information
when fetching a DatetimeIndex column with tz=UTC