Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
BUG: select_column not preserving a UTC timezone #7777
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 |
jreback
added Bug HDF5 Timezones
labels
Jul 17, 2014
jreback
added this to the
0.15.0
milestone
Jul 17, 2014
jreback
changed the title from
UTC timezone information lost from DatetimeIndex on _to_embed to BUG: select_column not preserving a UTC timezone
Jul 17, 2014
|
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 |
alorenzo175 commentedJul 17, 2014
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.pyin theIndex._to_embedmethod. 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: