<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pd.date_range(pd.Timestamp('2015-1-1', tz='US/Eastern'), pd.Timestamp('2016-1-1', tz='US/Eastern'), freq='H') + pd.DateOffset(days=1)

Traceback (most recent call last):
  File &quot;/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py&quot;, line 3066, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File &quot;&lt;ipython-input-21-9574a4185a77&gt;&quot;, line 1, in &lt;module&gt;
    pd.date_range(pd.Timestamp('2015-1-1', tz='US/Eastern'), pd.Timestamp('2016-1-1', tz='US/Eastern'), freq='H') + pd.DateOffset(days=1)
  File &quot;/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/tseries/base.py&quot;, line 412, in __add__
    return self._add_delta(other)
  File &quot;/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/tseries/index.py&quot;, line 731, in _add_delta
    new_values = self._add_offset(delta).asi8
  File &quot;/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/tseries/index.py&quot;, line 750, in _add_offset
    result = result.tz_localize(self.tz)
  File &quot;/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/util/decorators.py&quot;, line 89, in wrapper
    return func(*args, **kwargs)
  File &quot;/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/tseries/index.py&quot;, line 1724, in tz_localize
    ambiguous=ambiguous)
  File &quot;pandas/tslib.pyx&quot;, line 3781, in pandas.tslib.tz_localize_to_utc (pandas/tslib.c:64980)
NonExistentTimeError: 2015-03-08 02:00:00"><pre class="notranslate"><code class="notranslate">pd.date_range(pd.Timestamp('2015-1-1', tz='US/Eastern'), pd.Timestamp('2016-1-1', tz='US/Eastern'), freq='H') + pd.DateOffset(days=1)

Traceback (most recent call last):
  File "/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3066, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "&lt;ipython-input-21-9574a4185a77&gt;", line 1, in &lt;module&gt;
    pd.date_range(pd.Timestamp('2015-1-1', tz='US/Eastern'), pd.Timestamp('2016-1-1', tz='US/Eastern'), freq='H') + pd.DateOffset(days=1)
  File "/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/tseries/base.py", line 412, in __add__
    return self._add_delta(other)
  File "/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/tseries/index.py", line 731, in _add_delta
    new_values = self._add_offset(delta).asi8
  File "/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/tseries/index.py", line 750, in _add_offset
    result = result.tz_localize(self.tz)
  File "/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/util/decorators.py", line 89, in wrapper
    return func(*args, **kwargs)
  File "/home/jeff/.virtualenvs/omnipotent/local/lib/python2.7/site-packages/pandas/tseries/index.py", line 1724, in tz_localize
    ambiguous=ambiguous)
  File "pandas/tslib.pyx", line 3781, in pandas.tslib.tz_localize_to_utc (pandas/tslib.c:64980)
NonExistentTimeError: 2015-03-08 02:00:00
</code></pre></div>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 2.7.6.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 3.13.0-61-generic<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.UTF-8</p>
<p dir="auto">pandas: 0.17.1<br>
nose: None<br>
pip: 7.1.0<br>
setuptools: 18.0.1<br>
Cython: None<br>
numpy: 1.10.4<br>
scipy: 0.16.1<br>
statsmodels: None<br>
IPython: 4.0.3<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.4.2<br>
pytz: 2015.7<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
matplotlib: 1.5.0<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: 4.4.1<br>
html5lib: None<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: 1.0.11<br>
pymysql: None<br>
psycopg2: 2.6.1 (dt dec pq3 ext lo64)<br>
Jinja2: None</p>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import pandas as pd
&gt;&gt;&gt; idx = pd.DatetimeIndex(['2000-03-26 04:00'], tz='Europe/Berlin')  # Switch to DST was on that day
&gt;&gt;&gt; idx
DatetimeIndex(['2000-03-26 04:00:00+02:00'], dtype='datetime64[ns, Europe/Berlin]', freq=None)
&gt;&gt;&gt; idx + pd.DateOffset(hours=-2)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/var/local/conda/envs/pandas-debug/lib/python3.7/site-packages/pandas/core/indexes/datetimelike.py&quot;, line 510, in __add__
    result = self._data.__add__(maybe_unwrap_index(other))
  File &quot;/var/local/conda/envs/pandas-debug/lib/python3.7/site-packages/pandas/core/arrays/datetimelike.py&quot;, line 1212, in __add__
    result = self._add_offset(other)
  File &quot;/var/local/conda/envs/pandas-debug/lib/python3.7/site-packages/pandas/core/arrays/datetimes.py&quot;, line 832, in _add_offset
    result = result.tz_localize(self.tz)
  File &quot;/var/local/conda/envs/pandas-debug/lib/python3.7/site-packages/pandas/core/arrays/datetimes.py&quot;, line 1151, in tz_localize
    self.asi8, tz, ambiguous=ambiguous, nonexistent=nonexistent
  File &quot;pandas/_libs/tslibs/tzconversion.pyx&quot;, line 276, in pandas._libs.tslibs.tzconversion.tz_localize_to_utc
pytz.exceptions.NonExistentTimeError: 2000-03-26 02:00:00
&gt;&gt;&gt; idx[0] + pd.DateOffset(hours=-2)
Timestamp('2000-03-26 01:00:00+0100', tz='Europe/Berlin')"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">idx</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DatetimeIndex</span>([<span class="pl-s">'2000-03-26 04:00'</span>], <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s">'Europe/Berlin'</span>)  <span class="pl-c"># Switch to DST was on that day</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">idx</span>
<span class="pl-v">DatetimeIndex</span>([<span class="pl-s">'2000-03-26 04:00:00+02:00'</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns, Europe/Berlin]'</span>, <span class="pl-s1">freq</span><span class="pl-c1">=</span><span class="pl-c1">None</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">idx</span> <span class="pl-c1">+</span> <span class="pl-s1">pd</span>.<span class="pl-v">DateOffset</span>(<span class="pl-s1">hours</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">2</span>)
<span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>):
  <span class="pl-v">File</span> <span class="pl-s">"&lt;stdin&gt;"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>
  <span class="pl-v">File</span> <span class="pl-s">"/var/local/conda/envs/pandas-debug/lib/python3.7/site-packages/pandas/core/indexes/datetimelike.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">510</span>, <span class="pl-s1">in</span> <span class="pl-s1">__add__</span>
    <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">_data</span>.<span class="pl-en">__add__</span>(<span class="pl-en">maybe_unwrap_index</span>(<span class="pl-s1">other</span>))
  <span class="pl-v">File</span> <span class="pl-s">"/var/local/conda/envs/pandas-debug/lib/python3.7/site-packages/pandas/core/arrays/datetimelike.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1212</span>, <span class="pl-s1">in</span> <span class="pl-s1">__add__</span>
    <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">_add_offset</span>(<span class="pl-s1">other</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/var/local/conda/envs/pandas-debug/lib/python3.7/site-packages/pandas/core/arrays/datetimes.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">832</span>, <span class="pl-s1">in</span> <span class="pl-s1">_add_offset</span>
    <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">result</span>.<span class="pl-en">tz_localize</span>(<span class="pl-s1">self</span>.<span class="pl-s1">tz</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/var/local/conda/envs/pandas-debug/lib/python3.7/site-packages/pandas/core/arrays/datetimes.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1151</span>, <span class="pl-s1">in</span> <span class="pl-s1">tz_localize</span>
    <span class="pl-s1">self</span>.<span class="pl-s1">asi8</span>, <span class="pl-s1">tz</span>, <span class="pl-s1">ambiguous</span><span class="pl-c1">=</span><span class="pl-s1">ambiguous</span>, <span class="pl-s1">nonexistent</span><span class="pl-c1">=</span><span class="pl-s1">nonexistent</span>
  <span class="pl-v">File</span> <span class="pl-s">"pandas/_libs/tslibs/tzconversion.pyx"</span>, <span class="pl-s1">line</span> <span class="pl-c1">276</span>, <span class="pl-s1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">tslibs</span>.<span class="pl-s1">tzconversion</span>.<span class="pl-s1">tz_localize_to_utc</span>
<span class="pl-s1">pytz</span>.<span class="pl-s1">exceptions</span>.<span class="pl-v">NonExistentTimeError</span>: <span class="pl-c1">2000</span><span class="pl-c1">-</span><span class="pl-c1">03</span><span class="pl-c1">-</span><span class="pl-c1">26</span> <span class="pl-c1">02</span>:<span class="pl-c1">00</span>:<span class="pl-c1">00</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">idx</span>[<span class="pl-c1">0</span>] <span class="pl-c1">+</span> <span class="pl-s1">pd</span>.<span class="pl-v">DateOffset</span>(<span class="pl-s1">hours</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">2</span>)
<span class="pl-v">Timestamp</span>(<span class="pl-s">'2000-03-26 01:00:00+0100'</span>, <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s">'Europe/Berlin'</span>)</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">The vectorized operation <code class="notranslate">DatetimeIndex + DateOffset</code> is broken around the DST switching time. However, the same operation works element-wise (<code class="notranslate">Timestamp + DateOffset</code>), so I would expect either both versions to work (preferably) or both versions to fail with the same error.</p>
<h4 dir="auto">Expected Output</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="DatetimeIndex(['2000-03-26 01:00:00+01:00'], dtype='datetime64[ns, Europe/Berlin]', freq=None)"><pre class="notranslate"><span class="pl-v">DatetimeIndex</span>([<span class="pl-s">'2000-03-26 01:00:00+01:00'</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns, Europe/Berlin]'</span>, <span class="pl-s1">freq</span><span class="pl-c1">=</span><span class="pl-c1">None</span>)</pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit           : None<br>
python           : 3.7.4.final.0<br>
python-bits      : 64<br>
OS               : Linux<br>
OS-release       : 5.0.0-29-generic<br>
machine          : x86_64<br>
processor        : x86_64<br>
byteorder        : little<br>
LC_ALL           : None<br>
LANG             : en_US.UTF-8<br>
LOCALE           : en_US.UTF-8</p>
<p dir="auto">pandas           : 0.25.1<br>
numpy            : 1.16.5<br>
pytz             : 2019.2<br>
dateutil         : 2.8.0<br>
pip              : 19.2.3<br>
setuptools       : 41.2.0<br>
Cython           : None<br>
pytest           : None<br>
hypothesis       : None<br>
sphinx           : None<br>
blosc            : None<br>
feather          : None<br>
xlsxwriter       : None<br>
lxml.etree       : None<br>
html5lib         : None<br>
pymysql          : None<br>
psycopg2         : None<br>
jinja2           : None<br>
IPython          : None<br>
pandas_datareader: None<br>
bs4              : None<br>
bottleneck       : None<br>
fastparquet      : None<br>
gcsfs            : None<br>
lxml.etree       : None<br>
matplotlib       : None<br>
numexpr          : None<br>
odfpy            : None<br>
openpyxl         : None<br>
pandas_gbq       : None<br>
pyarrow          : None<br>
pytables         : None<br>
s3fs             : None<br>
scipy            : None<br>
sqlalchemy       : None<br>
tables           : None<br>
xarray           : None<br>
xlrd             : None<br>
xlwt             : None<br>
xlsxwriter       : None</p>
</details>