AmbiguousTimeError: Cannot infer dst time from Timestamp('2015-11-01 01:00:03'), try using the 'ambiguous' argument · Issue #14402 · pandas-dev/pandas (original) (raw)
In Pandas 0.19.0, there seems to be an error when setting the timezone for times close to the dst cutoff.
This issue appears very similar to #11619 and #11626, both of which have been closed. The traceback is below.
df['Timestamp'] = df['Timestamp Date'] + " " + df['Timestamp Time'] df['Timestamp'] = pd.to_datetime(df['Timestamp']).dt.tz_localize('US/Central')
AmbiguousTimeError Traceback (most recent call last) in () ----> 1 df['Timestamp'] = pd.to_datetime(df['Timestamp']).dt.tz_localize('US/Central')
/Users/adam/anaconda/lib/python2.7/site-packages/pandas/core/base.pyc in f(self, *args, **kwargs) 208 209 def f(self, *args, **kwargs): --> 210 return self._delegate_method(name, *args, **kwargs) 211 212 f.name = name
/Users/adam/anaconda/lib/python2.7/site-packages/pandas/tseries/common.pyc in _delegate_method(self, name, *args, **kwargs) 130 131 method = getattr(self.values, name) --> 132 result = method(*args, **kwargs) 133 134 if not is_list_like(result):
/Users/adam/anaconda/lib/python2.7/site-packages/pandas/util/decorators.pyc in wrapper(*args, **kwargs) 89 else: 90 kwargs[new_arg_name] = new_arg_value ---> 91 return func(*args, **kwargs) 92 return wrapper 93 return _deprecate_kwarg
/Users/adam/anaconda/lib/python2.7/site-packages/pandas/tseries/index.pyc in tz_localize(self, tz, ambiguous, errors) 1823 new_dates = tslib.tz_localize_to_utc(self.asi8, tz, 1824 ambiguous=ambiguous, -> 1825 errors=errors) 1826 new_dates = new_dates.view(_NS_DTYPE) 1827 return self._shallow_copy(new_dates, tz=tz)
pandas/tslib.pyx in pandas.tslib.tz_localize_to_utc (pandas/tslib.c:70327)()
AmbiguousTimeError: Cannot infer dst time from Timestamp('2015-11-01 01:00:03'), try using the 'ambiguous' argument
Here is some relevant information on the data frame.
df[['Timestamp Date', 'Timestamp Time', 'Timestamp']].head()
Timestamp Date Timestamp Time Timestamp
0 01-04-2016 07:10:03 AM 01-04-2016 07:10:03 AM
1 01-04-2016 07:20:04 AM 01-04-2016 07:20:04 AM
2 01-04-2016 07:30:03 AM 01-04-2016 07:30:03 AM
3 01-04-2016 07:40:03 AM 01-04-2016 07:40:03 AM
4 01-04-2016 07:50:03 AM 01-04-2016 07:50:03 AM
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 286834 entries, 0 to 286833
Timestamp Date 286834 non-null object
Timestamp Time 286834 non-null object
Timestamp 286834 non-null object
I also had this same issue in Pandas 0.18.0 before upgrading to 0.19.0.