-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Resample discards timezone information #13238
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
Comments
rewriting your example like how we test
datetime w/tz and resampling are not tested very much. pull-requests to do more of this are welcome (the fix is very straightforward). |
Thanks for the quick look! Note that your re-written example doesn't display the problem. You need to look at |
have a look again at [12] vs [14]. the time changed. (look t the hour). the issue is the re-localization is off. The actual tz is correct. |
I'm going to attempt fixing this one |
Wouldn't we expect the index values to be at midnight on each day given that we're aggregating up to the day level? If we run the code above without the timezones we get a similar output:
|
Any progress on this? Had to spend about 20 minutes figuring this out and it impacts all join operations as the timezones are not treated as equal despite having the same zone name. So all binary operations will result in losing timezone information ([13] below). Using tz_convert brings the timezone back in line, but shouldn't be necessary. Some more examples: In [11]: s = pd.Series([2], index=pd.date_range('2017-01-01', periods=48, freq="H", tz="US/Eastern"))
In [12]: ss = s / s.resample("D").mean()
In [13]: ss.dropna()
Out[13]:
2017-01-01 05:00:00+00:00 1.0
2017-01-02 05:00:00+00:00 1.0
dtype: float64
In [14]: ss1 = s / s.resample("D").mean().tz_convert("US/Eastern")
In [15]: ss1.dropna()
Out[15]:
2017-01-01 00:00:00-05:00 1.0
2017-01-02 00:00:00-05:00 1.0
dtype: float64
In [16]: s.resample("D").mean()
Out[16]:
2017-01-01 00:00:00-05:00 2
2017-01-02 00:00:00-05:00 2
In [22]: s.resample("D").mean().index.tz
Out[22]: <DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>
In [23]: s.index.tz
Out[23]: <DstTzInfo 'US/Eastern' LMT-1 day, 19:04:00 STD> |
i think #18596 will fix this if u want to give that a try |
Yes, that will fix the join issue. Thanks. |
ohh great lmk rebase that tomorrow i suspect this will close a number of other issues as well |
Yeah, I agree it doesn't fix the resample, just the join issue ([13] in my example). It works despite resample returning a different tzinfo, so half the battle. |
It appears that resample is now dropping timezone information on the index. Is this expected?
produces the following in 0.16.1. Notably the timezones for the original series and the resampled series are the same.
However that's not the case for 0.18.1. Caveat is that we're using the new resample syntax:
b = a.resample('D').max()
The text was updated successfully, but these errors were encountered: