Skip to content

bug with time fields when using timezones #1673

@killinc

Description

@killinc
# 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...

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