Skip to content

hours are wrong for DatetimeIndex with timezone set #1946

Closed
@adamgreenhall

Description

@adamgreenhall

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions