Skip to content

.dt error when handling Series across daylight savings boundary #11648

@nasrallah

Description

@nasrallah
import pandas as pd
## two timepoints in UTC flanking the US/Eastern DST shift
date_strings = ['2015-11-01T05:00:00Z', '2015-11-01T07:00:00Z']
S = pd.Series(date_strings)
## Convert to US/Eastern 
S = pd.to_datetime(S).apply(lambda x: x.tz_localize('UTC').tz_convert('US/Eastern'))
S.dt.dayofweek
## AttributeError: Can only use .dt accessor with datetimelike values

## Note: the problem does not arise if the US/Eastern version of the times are on different days
## e.g. if date_strings = ['2015-11-01T03:00:00Z', '2015-11-01T07:00:00Z']

Using python 3.4 and pandas 0.17.0.
When a Series contains two time-zone aware datetimes on the 'same day' in the local time zone on either side of the Fall 2015 daylight savings time shift, calling .dt produces an attribute error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions