-
Notifications
You must be signed in to change notification settings - Fork 909
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
Make DatetimeIndex timezone naive for compatibility with xarray/numpy engine #1343
Conversation
…upported by xarray): timezone information is removed without convertion. added associated tests
Codecov ReportBase: 93.89% // Head: 93.88% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #1343 +/- ##
==========================================
- Coverage 93.89% 93.88% -0.01%
==========================================
Files 78 78
Lines 8516 8510 -6
==========================================
- Hits 7996 7990 -6
Misses 520 520
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Looks good! I just have suggestions for slightly better warning messages, and also to remove the print()
statements.
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.
Thanks 👍
Fixes #1052 and #648. Xarray relies on numpy engine, which is not timezone aware. Causes issues for plotting and resampling.
Summary
When constructing a
TimeSeries
from apd.DataFrame
or apd.Series
with aDatetimeIndex
containing timezone information, this attribute is dropped without conversion usingtz_localize(None)
(conversion can causes shift in the timestamps, making the index invalid). The timezone information can be recovered by callingts.time_index.tz_localize(original_tz)
prior to exporting the data.Other Information
The
DatetimeIndex
not used as index are silently converted to UTC by thepd.DataFrame
constructor without saving the timezone information. Thus, timezone aware dataset should use the time range as index to take advantage of the bugfix and avoid the error raised by theTimeSeries
constructor due to index invalidity.In order to have the desired x-axis when plotting the
TimeSeries
(with a timezone unawaretime_index
due to the bugfix), the user can simply leverage the matplotlib.pyplotrcParams['timezone']
parameter to automatically convert the time axis back to the original timezone.