-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: select_column not preserving a UTC timezone #7777
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
this is an internal method show a complete example of what u r actually doing |
Making a Series of a DatetimeIndex also illustrates the problem. import pandas as pd
drange = pd.date_range('2014-07-07 00:00:00', '2014-07-07 03:00:00', freq='1h')
drange_utc = drange.tz_localize('UTC')
drange_mst = drange.tz_localize('MST')
print pd.Series(drange)
print pd.Series(drange_utc)
print pd.Series(drange_mst) |
And an example of my original problem getting the index from an HDF store import pandas as pd
import numpy as np
drange = pd.date_range('2014-07-07 00:00:00', '2014-07-07 03:00:00', freq='1h')
drange_utc = drange.tz_localize('UTC')
drange_mst = drange.tz_localize('MST')
data = np.ones((drange.size, 3))
df_utc = pd.DataFrame(data, index=drange_utc)
df_mst = pd.DataFrame(data, index=drange_mst)
store_path = 'timezone_test.h5'
with pd.get_store(store_path) as store:
store.put('utc', df_utc ,'table')
store.put('mst', df_mst, 'table')
with pd.get_store(store_path) as store:
print store.select_column('utc', 'index')
print store.select_column('mst', 'index') |
@alorenzo175 By definition a Because a UTC series is de-facto equivalent to a plain-old I guess this could be a bit confusing. A possible work-around is to store the 'UTC' data as 'GMT', which will be treated as a regular timezone. selecting this as a full table DOES seem to work though (e.g. ok, will mark that as a bug. interested in doing a pull-request to fix (it will be in |
After messing around a little with the I'll try to make a fix but this will be my virgin PR. |
@alorenzo175 np, I don't think its that tricky, but have to get to know the code...lmk |
https://github.com/pydata/pandas/wiki some useful tips |
I was having issues with lost tz-info when retrieving a DatetimeIndex from an HDF store using
store.select_column('data', 'index')
. I was able to track down the issue totseries/index.py
in theIndex._to_embed
method. The issue isIt looks like it explicitly rejects UTC timezones. Is there a good reason for this?
The below code reproduces the problem for me.
I'm using python 2.7.6 with the following packages:
The text was updated successfully, but these errors were encountered: