-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Description
# the following code fails
dr = date_range('2012-01-01','2012-01-10',freq = 'D', tz = 'Hongkong')
dr.hour
# whereas this doesn't
dr = date_range('2012-01-01','2012-01-10',freq = 'D')
dr.hour
The reason that this is an important use case is that often you have data stored in UTC but want to sample at a particular time of day in another region.
For some dataframe y whose index is timezone aware, I would like to be able to say x = y[y.index.hour == 1]
Instead I need to write:
hours = [dt.hour for dt in y.index]
x = y[hours == 1]
this is ok but the list comprehension step takes ages because it is created a new timestamp for each underlying numpy datetime...