-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Milestone
Description
Second tz_convert fails with AmbiguousTimeError ('UTC' in the example, but other timezones fail too).
EDIT: Actually it's not only second tz_convert that fails, it looks like most (if not all) of the .dt accessed properties are affected
t = pd.Series(pd.date_range('2015-01-01', '2016-01-01', freq='T')) t = t.dt.tz_localize('UTC').dt.tz_convert('America/Chicago') t.head(10)0 2014-12-31 18:00:00-06:00 1 2014-12-31 18:01:00-06:00 2 2014-12-31 18:02:00-06:00 3 2014-12-31 18:03:00-06:00 4 2014-12-31 18:04:00-06:00 5 2014-12-31 18:05:00-06:00 6 2014-12-31 18:06:00-06:00 7 2014-12-31 18:07:00-06:00 8 2014-12-31 18:08:00-06:00 9 2014-12-31 18:09:00-06:00 dtype: datetime64[ns, America/Chicago] t.dt.tz_convert('UTC')--------------------------------------------------------------------------- AmbiguousTimeError Traceback (most recent call last) /usr/lib/python3.5/site-packages/pandas/core/series.py in _make_dt_accessor(self) 2639 try: -> 2640 return maybe_to_datetimelike(self) 2641 except Exception: /usr/lib/python3.5/site-packages/pandas/tseries/common.py in maybe_to_datetimelike(data, copy) 48 if is_datetime64_dtype(data.dtype) or is_datetime64tz_dtype(data.dtype): ---> 49 return DatetimeProperties(DatetimeIndex(data, copy=copy, freq='infer'), index, name=data.name) 50 elif is_timedelta64_dtype(data.dtype): /usr/lib/python3.5/site-packages/pandas/util/decorators.py in wrapper(*args, **kwargs) 88 kwargs[new_arg_name] = new_arg_value ---> 89 return func(*args, **kwargs) 90 return wrapper /usr/lib/python3.5/site-packages/pandas/tseries/index.py in __new__(cls, data, freq, start, end, periods, copy, name, tz, verify_integrity, normalize, closed, ambiguous, dtype, **kwargs) 343 subarr = tslib.tz_localize_to_utc(ints, tz, --> 344 ambiguous=ambiguous) 345 pandas/tslib.pyx in pandas.tslib.tz_localize_to_utc (pandas/tslib.c:64516)() AmbiguousTimeError: Cannot infer dst time from Timestamp('2015-11-01 01:00:00'), try using the 'ambiguous' argument During handling of the above exception, another exception occurred: AttributeError Traceback (most recent call last) <ipython-input-2-eb75730cd6fc> in <module>() ----> 1 t.dt.tz_convert('UTC') /usr/lib/python3.5/site-packages/pandas/core/generic.py in __getattr__(self, name) 2239 or name in self._metadata 2240 or name in self._accessors): -> 2241 return object.__getattribute__(self, name) 2242 else: 2243 if name in self._info_axis: /usr/lib/python3.5/site-packages/pandas/core/base.py in __get__(self, instance, owner) 186 # this ensures that Series.str.<method> is well defined 187 return self.accessor_cls --> 188 return self.construct_accessor(instance) 189 190 def __set__(self, instance, value): /usr/lib/python3.5/site-packages/pandas/core/series.py in _make_dt_accessor(self) 2640 return maybe_to_datetimelike(self) 2641 except Exception: -> 2642 raise AttributeError("Can only use .dt accessor with datetimelike " 2643 "values") 2644 AttributeError: Can only use .dt accessor with datetimelike values