<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="import pandas as pd

dates = pd.date_range('2017-01-01', '2017-01-31', tz='UTC')
deltas = pd.TimedeltaIndex(pd.np.arange(0, len(dates)), unit='m')
dates + deltas

# Removing the tz='UTC' (making dates tz naive) works"><pre class="notranslate"><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-s1">dates</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">date_range</span>(<span class="pl-s">'2017-01-01'</span>, <span class="pl-s">'2017-01-31'</span>, <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s">'UTC'</span>)
<span class="pl-s1">deltas</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">TimedeltaIndex</span>(<span class="pl-s1">pd</span>.<span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">0</span>, <span class="pl-en">len</span>(<span class="pl-s1">dates</span>)), <span class="pl-s1">unit</span><span class="pl-c1">=</span><span class="pl-s">'m'</span>)
<span class="pl-s1">dates</span> <span class="pl-c1">+</span> <span class="pl-s1">deltas</span>

<span class="pl-c"># Removing the tz='UTC' (making dates tz naive) works</span></pre></div>
<p dir="auto">throws:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="TypeError                                 Traceback (most recent call last)
&lt;ipython-input-28-708df3869f57&gt; in &lt;module&gt;()
      3 dates = pd.date_range('2017-01-01', '2017-01-31', tz='UTC')
      4 deltas = pd.TimedeltaIndex(pd.np.arange(0, len(dates)), unit='m')
----&gt; 5 dates + deltas

~/miniconda/lib/python3.6/site-packages/pandas/core/indexes/datetimelike.py in __add__(self, other)
    643             from pandas.tseries.offsets import DateOffset
    644             if isinstance(other, TimedeltaIndex):
--&gt; 645                 return self._add_delta(other)
    646             elif isinstance(self, TimedeltaIndex) and isinstance(other, Index):
    647                 if hasattr(other, '_add_delta'):

~/miniconda/lib/python3.6/site-packages/pandas/core/indexes/datetimes.py in _add_delta(self, delta)
    814             new_values = self._add_delta_td(delta)
    815         elif isinstance(delta, TimedeltaIndex):
--&gt; 816             new_values = self._add_delta_tdi(delta)
    817             # update name when delta is Index
    818             name = com._maybe_match_name(self, delta)

~/miniconda/lib/python3.6/site-packages/pandas/core/indexes/datetimelike.py in _add_delta_tdi(self, other)
    727             mask = (self._isnan) | (other._isnan)
    728             new_values[mask] = iNaT
--&gt; 729         return new_values.view(self.dtype)
    730 
    731     def isin(self, values):

TypeError: data type not understood"><pre class="notranslate"><span class="pl-v">TypeError</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-c1">&lt;</span><span class="pl-s1">ipython</span><span class="pl-c1">-</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-c1">28</span><span class="pl-c1">-</span><span class="pl-c1">708</span><span class="pl-s1">df3869f57</span><span class="pl-c1">&gt;</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-c1">3</span> <span class="pl-s1">dates</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">date_range</span>(<span class="pl-s">'2017-01-01'</span>, <span class="pl-s">'2017-01-31'</span>, <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s">'UTC'</span>)
      <span class="pl-c1">4</span> <span class="pl-s1">deltas</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">TimedeltaIndex</span>(<span class="pl-s1">pd</span>.<span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">0</span>, <span class="pl-en">len</span>(<span class="pl-s1">dates</span>)), <span class="pl-s1">unit</span><span class="pl-c1">=</span><span class="pl-s">'m'</span>)
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">5</span> <span class="pl-s1">dates</span> <span class="pl-c1">+</span> <span class="pl-s1">deltas</span>

<span class="pl-c1">~</span><span class="pl-c1">/</span><span class="pl-s1">miniconda</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python3</span>.<span class="pl-c1">6</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">core</span><span class="pl-c1">/</span><span class="pl-s1">indexes</span><span class="pl-c1">/</span><span class="pl-s1">datetimelike</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">__add__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">other</span>)
    <span class="pl-c1">643</span>             <span class="pl-k">from</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">tseries</span>.<span class="pl-s1">offsets</span> <span class="pl-k">import</span> <span class="pl-v">DateOffset</span>
    <span class="pl-c1">644</span>             <span class="pl-k">if</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">other</span>, <span class="pl-v">TimedeltaIndex</span>):
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">645</span>                 <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_add_delta</span>(<span class="pl-s1">other</span>)
    <span class="pl-c1">646</span>             <span class="pl-s1">elif</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">self</span>, <span class="pl-v">TimedeltaIndex</span>) <span class="pl-c1">and</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">other</span>, <span class="pl-v">Index</span>):
    <span class="pl-c1">647</span>                 <span class="pl-k">if</span> <span class="pl-en">hasattr</span>(<span class="pl-s1">other</span>, <span class="pl-s">'_add_delta'</span>):

<span class="pl-c1">~</span><span class="pl-c1">/</span><span class="pl-s1">miniconda</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python3</span>.<span class="pl-c1">6</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">core</span><span class="pl-c1">/</span><span class="pl-s1">indexes</span><span class="pl-c1">/</span><span class="pl-s1">datetimes</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">_add_delta</span>(<span class="pl-s1">self</span>, <span class="pl-s1">delta</span>)
    <span class="pl-c1">814</span>             <span class="pl-s1">new_values</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">_add_delta_td</span>(<span class="pl-s1">delta</span>)
    <span class="pl-c1">815</span>         <span class="pl-k">elif</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">delta</span>, <span class="pl-v">TimedeltaIndex</span>):
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">816</span>             <span class="pl-s1">new_values</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">_add_delta_tdi</span>(<span class="pl-s1">delta</span>)
    <span class="pl-c1">817</span>             <span class="pl-c"># update name when delta is Index</span>
    <span class="pl-c1">818</span>             <span class="pl-s1">name</span> <span class="pl-c1">=</span> <span class="pl-s1">com</span>.<span class="pl-en">_maybe_match_name</span>(<span class="pl-s1">self</span>, <span class="pl-s1">delta</span>)

<span class="pl-c1">~</span><span class="pl-c1">/</span><span class="pl-s1">miniconda</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python3</span>.<span class="pl-c1">6</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">core</span><span class="pl-c1">/</span><span class="pl-s1">indexes</span><span class="pl-c1">/</span><span class="pl-s1">datetimelike</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">_add_delta_tdi</span>(<span class="pl-s1">self</span>, <span class="pl-s1">other</span>)
    <span class="pl-c1">727</span>             <span class="pl-s1">mask</span> <span class="pl-c1">=</span> (<span class="pl-s1">self</span>.<span class="pl-s1">_isnan</span>) <span class="pl-c1">|</span> (<span class="pl-s1">other</span>.<span class="pl-s1">_isnan</span>)
    <span class="pl-c1">728</span>             <span class="pl-s1">new_values</span>[<span class="pl-s1">mask</span>] <span class="pl-c1">=</span> <span class="pl-s1">iNaT</span>
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">729</span>         <span class="pl-s1">return</span> <span class="pl-s1">new_values</span>.<span class="pl-en">view</span>(<span class="pl-s1">self</span>.<span class="pl-s1">dtype</span>)
    <span class="pl-c1">730</span> 
    <span class="pl-c1">731</span>     <span class="pl-s1">def</span> <span class="pl-en">isin</span>(<span class="pl-s1">self</span>, <span class="pl-s1">values</span>):

<span class="pl-v">TypeError</span>: <span class="pl-s1">data</span> <span class="pl-s1">type</span> <span class="pl-c1">not</span> <span class="pl-s1">understood</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">Adding TimedeltaIndex to timezone-aware DatetimeIndex throws a TypeError.  The error goes away if the DatetimeIndex does not have a timezone.</p>
<p dir="auto">(I vaguely remember seeing an issue on this, but can't seem to find it now when I search.)</p>
<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.6.2.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.10.0-33-generic<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: C.UTF-8<br>
LANG: C.UTF-8<br>
LOCALE: en_US.UTF-8</p>
<p dir="auto">pandas: 0.21.0<br>
pytest: None<br>
pip: 9.0.1<br>
setuptools: 36.5.0.post20170921<br>
Cython: None<br>
numpy: 1.13.3<br>
scipy: 0.19.1<br>
pyarrow: None<br>
xarray: None<br>
IPython: 6.2.1<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.1<br>
pytz: 2017.3<br>
blosc: None<br>
bottleneck: None<br>
tables: 3.4.2<br>
numexpr: 2.6.4<br>
feather: None<br>
matplotlib: 2.1.0<br>
openpyxl: None<br>
xlrd: 1.0.0<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: 4.6.0<br>
html5lib: 0.9999999<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.10<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>
<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="
In [1]: import numpy as np, pandas as pd

In [2]: dt = pd.DatetimeIndex([pd.Timestamp(&quot;2017/01/01&quot;)], tz='US/Eastern')  # dtype=datetime64[ns, US/Eastern]

In [3]: td_np = np.array([np.timedelta64(1, 'ns')])  # dtype=&quot;timedelta64[ns]&quot;

In [4]: (dt + td_np).values  # Bad, &quot;applies&quot; TZ twice to get 10:00 instead of 05:00!
Out[4]: array(['2017-01-01T10:00:00.000000001'], dtype='datetime64[ns]')

In [5]: (dt + td_np[0]).values
Out[5]: array(['2017-01-01T05:00:00.000000001'], dtype='datetime64[ns]')

In [6]: (dt + pd.Series(td_np)).values
Out[6]: array(['2017-01-01T05:00:00.000000001'], dtype='datetime64[ns]')

In [7]: (dt.tz_convert(None) + td_np).values
Out[7]: array(['2017-01-01T05:00:00.000000001'], dtype='datetime64[ns]')

In [8]: (dt.values + td_np)
Out[8]: array(['2017-01-01T05:00:00.000000001'], dtype='datetime64[ns]')

In [9]: (dt + pd.TimedeltaIndex(td_np))
TypeError: data type not understood"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">1</span>]: <span class="pl-s1">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>, <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>

<span class="pl-v">In</span> [<span class="pl-c1">2</span>]: <span class="pl-s1">dt</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DatetimeIndex</span>([<span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>(<span class="pl-s">"2017/01/01"</span>)], <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s">'US/Eastern'</span>)  <span class="pl-c"># dtype=datetime64[ns, US/Eastern]</span>

<span class="pl-v">In</span> [<span class="pl-c1">3</span>]: <span class="pl-s1">td_np</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">np</span>.<span class="pl-en">timedelta64</span>(<span class="pl-c1">1</span>, <span class="pl-s">'ns'</span>)])  <span class="pl-c"># dtype="timedelta64[ns]"</span>

<span class="pl-v">In</span> [<span class="pl-c1">4</span>]: (<span class="pl-s1">dt</span> <span class="pl-c1">+</span> <span class="pl-s1">td_np</span>).<span class="pl-s1">values</span>  <span class="pl-c"># Bad, "applies" TZ twice to get 10:00 instead of 05:00!</span>
<span class="pl-v">Out</span>[<span class="pl-c1">4</span>]: <span class="pl-en">array</span>([<span class="pl-s">'2017-01-01T10:00:00.000000001'</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns]'</span>)

<span class="pl-v">In</span> [<span class="pl-c1">5</span>]: (<span class="pl-s1">dt</span> <span class="pl-c1">+</span> <span class="pl-s1">td_np</span>[<span class="pl-c1">0</span>]).<span class="pl-s1">values</span>
<span class="pl-v">Out</span>[<span class="pl-c1">5</span>]: <span class="pl-en">array</span>([<span class="pl-s">'2017-01-01T05:00:00.000000001'</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns]'</span>)

<span class="pl-v">In</span> [<span class="pl-c1">6</span>]: (<span class="pl-s1">dt</span> <span class="pl-c1">+</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">td_np</span>)).<span class="pl-s1">values</span>
<span class="pl-v">Out</span>[<span class="pl-c1">6</span>]: <span class="pl-en">array</span>([<span class="pl-s">'2017-01-01T05:00:00.000000001'</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns]'</span>)

<span class="pl-v">In</span> [<span class="pl-c1">7</span>]: (<span class="pl-s1">dt</span>.<span class="pl-en">tz_convert</span>(<span class="pl-c1">None</span>) <span class="pl-c1">+</span> <span class="pl-s1">td_np</span>).<span class="pl-s1">values</span>
<span class="pl-v">Out</span>[<span class="pl-c1">7</span>]: <span class="pl-en">array</span>([<span class="pl-s">'2017-01-01T05:00:00.000000001'</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns]'</span>)

<span class="pl-v">In</span> [<span class="pl-c1">8</span>]: (<span class="pl-s1">dt</span>.<span class="pl-s1">values</span> <span class="pl-c1">+</span> <span class="pl-s1">td_np</span>)
<span class="pl-v">Out</span>[<span class="pl-c1">8</span>]: <span class="pl-en">array</span>([<span class="pl-s">'2017-01-01T05:00:00.000000001'</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns]'</span>)

<span class="pl-v">In</span> [<span class="pl-c1">9</span>]: (<span class="pl-s1">dt</span> <span class="pl-c1">+</span> <span class="pl-s1">pd</span>.<span class="pl-v">TimedeltaIndex</span>(<span class="pl-s1">td_np</span>))
<span class="pl-v">TypeError</span>: <span class="pl-s1">data</span> <span class="pl-s1">type</span> <span class="pl-c1">not</span> <span class="pl-s1">understood</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">(Above is run on 0.20.3) When adding a tz-aware <code class="notranslate">DatetimeIndex</code> and a numpy array of timedeltas, the result incorrectly has the timezone applied twice. There are several related issues on tz-aware <code class="notranslate">DatetimeIndex</code> and <code class="notranslate">timedelta</code> sums on the issue tracker, for example <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="171675171" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/14022" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/14022/hovercard" href="https://github.com/pandas-dev/pandas/issues/14022">#14022</a>. However, as far as I've read, those issues appear to have been mostly resolved as of ~0.19; this case just slipped through the cracks. I haven't found any other variants of this bug, except maybe that tz-aware <code class="notranslate">DatetimeIndex + TimedeltaIndex</code> raises an exception.</p>
<p dir="auto">(Just for context, I am not relying on this behavior, just happened to come across it while updating some tests to use pandas 0.20.3, but it could lead to someone silently getting incorrect results.)</p>
<p dir="auto">I think all that needs to be fixed here is to add another case in <code class="notranslate">pd.DatetimeIndex[OpsMixin].__add__</code> to handle any array-like with <code class="notranslate">dtype=timedelta64[..]</code>. (Maybe there's a more general upstream solution?) If someone confirms I can submit a patch.</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="
In [4]: (dt + td_np).values
Out[5]: array(['2017-01-01T05:00:00.000000001'], dtype='datetime64[ns]')"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">4</span>]: (<span class="pl-s1">dt</span> <span class="pl-c1">+</span> <span class="pl-s1">td_np</span>).<span class="pl-s1">values</span>
<span class="pl-v">Out</span>[<span class="pl-c1">5</span>]: <span class="pl-en">array</span>([<span class="pl-s">'2017-01-01T05:00:00.000000001'</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns]'</span>)</pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.75-el6.x86_64.lime.1
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
<p dir="auto">pandas: 0.20.3<br>
pytest: 2.9.1<br>
pip: 7.1.0<br>
setuptools: 19.4<br>
Cython: 0.24<br>
numpy: 1.13.1<br>
scipy: 0.17.0<br>
xarray: None<br>
IPython: 5.1.0<br>
sphinx: 1.4.5<br>
patsy: 0.4.1<br>
dateutil: 2.2<br>
pytz: 2015.2<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
feather: None<br>
matplotlib: 1.5.3<br>
openpyxl: 1.8.6<br>
xlrd: 0.9.3<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: 3.6.0<br>
bs4: 4.4.0<br>
html5lib: None<br>
sqlalchemy: 1.0.12<br>
pymysql: 0.6.3.None<br>
psycopg2: None<br>
jinja2: 2.9.6<br>
s3fs: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>