Skip to content

hours are wrong for DatetimeIndex with timezone set #1946

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

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

hours are wrong for DatetimeIndex with timezone set #1946

adamgreenhall opened this issue Sep 21, 2012 · 3 comments
Labels
Milestone

Comments

@adamgreenhall
Copy link
Contributor

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
Copy link
Contributor Author

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

@wesm
Copy link
Member

wesm commented Sep 23, 2012

Looking...

@wesm wesm closed this as completed in 8c0e206 Sep 23, 2012
@wesm
Copy link
Member

wesm commented Sep 23, 2012

thanks for catching, fixed!

wesm added a commit that referenced this issue Sep 25, 2012
* 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
* 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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants