Closed
Description
First two examples pass, third example doesn't.
# GH 4629
# arithmetic datetime64 ops with an index
s = Series(date_range('20130101',periods=5),index=date_range('20130101',periods=5))
expected = s-s.index.to_series()
result = s-s.index
assert_series_equal(result,expected)
result = s-s.index.to_period()
assert_series_equal(result,expected)
result2 = s.index.to_period() - s
expected2 = s.index.to_series() - s
assert_series_equal(result2, expected2)
Traceback:
/usr/local/bin/vim +2583 pandas/tests/test_series.py # test_datetime64_with_index
result2 = s.index.to_period() - s
/usr/local/bin/vim +873 pandas/tseries/period.py # __sub__
return PeriodIndex(ordinal=self.values - other, freq=self.freq)
TypeError: ufunc subtract cannot use operands with types dtype('int64') and dtype('<M8[ns]')