Skip to content
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

hours are wrong for DatetimeIndex with timezone set #1946

Closed
adamgreenhall opened this issue Sep 21, 2012 · 3 comments

Comments

@adamgreenhall
Copy link
Contributor

commented Sep 21, 2012

Using hours on a basic hourly DatetimeIndex with a time zone gives the incorrect hours.

import pandas
from pandas.io.parsers import read_csv
timezone = 'America/Atikokan'
filename = 'forecast.csv'
data = read_csv(filename, index_col=0, header=None, squeeze=True)
data.index = pandas.DatetimeIndex(data.index).tz_localize(timezone)
print data.index[:10]
print [str(t) for t in data.index[:10]]
print data.index.hour[:10]

<class 'pandas.tseries.index.DatetimeIndex'>
[2011-10-02 00:00:00, ..., 2011-10-02 09:00:00]
Length: 10, Freq: None, Timezone: America/Atikokan

['2011-10-02 00:00:00-05:00', '2011-10-02 01:00:00-05:00', '2011-10-02 02:00:00-05:00', '2011-10-02 03:00:00-05:00', '2011-10-02 04:00:00-05:00', '2011-10-02 05:00:00-05:00', '2011-10-02 06:00:00-05:00', '2011-10-02 07:00:00-05:00', '2011-10-02 08:00:00-05:00', '2011-10-02 09:00:00-05:00']

[ 9 9 19 19 23 0 1 2 3 4]

@adamgreenhall

This comment has been minimized.

Copy link
Contributor Author

commented Sep 21, 2012

work-around
numpy.array([t.hour for t in data.index])

@wesm

This comment has been minimized.

Copy link
Member

commented Sep 23, 2012

Looking...

@wesm wesm closed this in 8c0e206 Sep 23, 2012

@wesm

This comment has been minimized.

Copy link
Member

commented Sep 23, 2012

thanks for catching, fixed!

wesm added a commit that referenced this issue Sep 25, 2012
Merge branch 'master' into c-parser
* master: (171 commits)
  BUG: fix Cython tz_convert bug with time zones that haven't had a UTC transition in a long time. close #1946
  BUG: fix buglet
  BUG: try fixing tzlocal bug
  Minor fixes to time series doc.
  Adding DataFrame methods to API reference.
  Added Series functions to API doc.
  BUG: fix segfault in SeriesGrouper with non-contiguous index
  RLS: Version 0.9.0 Release Candidate 1
  BLD: add lib depends #1945
  BUG: missing case for assigning DataFrame via ix
  BUG: python 3.1 timedelta compat issue
  BUG: python 3 tzoffset is not hashable
  TST: adds dateutil to travis-ci install commands
  BUG: let selecting multiple columns in DataFrame.__getitem__ work when there are duplicates. close #1943
  BUG: DatetimeConverter does not handle datetime64 arrays properly
  BUG: reindex with axis=1 when setting Series to scalar location, close #1942
  BUG: fix formatting of Timestamps in to_html/IPython notebook. refactor to_html code. close #1940
  ENH: allow single str input to na_values #1944
  TST: when xlrd is not installed skip tests needing it, close #1941
  BUG: DatetimeIndex localizes twice if input is localized DatetimeIndex #1838
  ...
yarikoptic added a commit to neurodebian/pandas that referenced this issue Sep 27, 2012
Merge commit 'v0.9.0rc1-7-g8c0e206' into debian
* commit 'v0.9.0rc1-7-g8c0e206':
  BUG: fix Cython tz_convert bug with time zones that haven't had a UTC transition in a long time. close pandas-dev#1946
  BUG: fix buglet
  BUG: try fixing tzlocal bug
  Minor fixes to time series doc.
  Adding DataFrame methods to API reference.
  Added Series functions to API doc.
  BUG: fix segfault in SeriesGrouper with non-contiguous index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.