You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [19]: dr=pd.date_range("20161123 00:00", "20161123 02:00", freq="H")
In [20]: tdr=pd.timedelta_range("1 minute", "3 minutes", freq="T")
In [21]: dr+tdrOut[21]:
DatetimeIndex(['2016-11-23 00:01:00', '2016-11-23 01:02:00',
'2016-11-23 02:03:00'],
dtype='datetime64[ns]', freq='61T')
In [22]: dr_tz=pd.date_range("20161123 00:00", "20161123 02:00", freq="H", tz="America/New_York")
...:
In [23]: dr_tz+tdr---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)
<ipython-input-23-c10d4a537816>in<module>()
---->1dr_tz+tdrC:\Anaconda\envs\bleeding\lib\site-packages\pandas\tseries\base.pycin__add__(self, other)
617frompandas.tseries.offsetsimportDateOffset618ifisinstance(other, TimedeltaIndex):
-->619returnself._add_delta(other)
620elifisinstance(self, TimedeltaIndex) andisinstance(other, Index):
621ifhasattr(other, '_add_delta'):
C:\Anaconda\envs\bleeding\lib\site-packages\pandas\tseries\index.pycin_add_delta(self, delta)
787new_values=self._add_delta_td(delta)
788elifisinstance(delta, TimedeltaIndex):
-->789new_values=self._add_delta_tdi(delta)
790# update name when delta is Index 791name=com._maybe_match_name(self, delta)
C:\Anaconda\envs\bleeding\lib\site-packages\pandas\tseries\base.pycin_add_delta_tdi(self, other)
704mask= (self._isnan) | (other._isnan)
705new_values[mask] =tslib.iNaT-->706returnnew_values.view(self.dtype)
707708defisin(self, values):
TypeError: datatypenotunderstood
Problem description
Given a DatetimeIndex that is not tz-aware, adding a TimedeltaIndex of the same length adds the values elementwise, as one would expect. Given a tz-aware DatetimeIndex, however, adding a TimedeltaIndex results in TypeError. Performing the same operation by iterating over the tz-aware index and adding the values directly works in the expected manner. This behavior did not occur under pandas 0.16.2; however, the above behavior occurs under at least 0.19.1 and the latest master.
Expected Output
Equivalent to the elementwise operation below, which works on latest master:
Code Sample, a copy-pastable example if possible
Under 0.19.1 and latest master:
Problem description
Given a DatetimeIndex that is not tz-aware, adding a TimedeltaIndex of the same length adds the values elementwise, as one would expect. Given a tz-aware DatetimeIndex, however, adding a TimedeltaIndex results in TypeError. Performing the same operation by iterating over the tz-aware index and adding the values directly works in the expected manner. This behavior did not occur under pandas 0.16.2; however, the above behavior occurs under at least 0.19.1 and the latest master.
Expected Output
Equivalent to the elementwise operation below, which works on latest master:
This also worked under 0.16.2:
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.19.0+98.gc045e1d
nose: 1.3.7
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.24.1
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: 1.4.8
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: 2.4.0
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: None
lxml: 3.6.4
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: