delegate (most) datetimelike Series arithmetic ops to DatetimeIndex
State: closed

DatetimeIndex arithmetic ops do overflow checks that Series does not.  Instead of re-implementing those checks (which I tried and its a PITA) this PR just delegates the appropriate operations to the DatetimeIndex implementation.

There are a couple of things that are missing from the DatetimeIndex implementations, e.g. the int-array case added to indexes.datetimelike.  If there's consensus that having a single implementation for these ops is the way to go, I'll port the other cases over in their own PRs.

If/when these implementations get merged, ops._TimeOp can be trimmed/removed.

- [x] closes #12534
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Docs
name: Timedelta
description: Timedelta data type

Comments:
Hello @jbrockmendel! Thanks for updating the PR.











Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on December 19, 2017 at 16:11 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18817?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@07d8c2d`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/18817/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/18817?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #18817   +/-   ##
=========================================
  Coverage          ?    91.6%           
=========================================
  Files             ?      154           
  Lines             ?    51452           
  Branches          ?        0           
=========================================
  Hits              ?    47135           
  Misses            ?     4317           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.47% <100%> (?)` | |
| #single | `40.8% <61.29%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18817?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/18817/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `90.56% <100%> (ø)` | |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/18817/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `97.16% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18817?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18817?src=pr&el=footer). Last update [07d8c2d...ab75018](https://codecov.io/gh/pandas-dev/pandas/pull/18817?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

The other arithmetic PRs are a couple steps away from really being ready for this.  The only part of this that is separately actionable (and on which I need input) is for where (and I guess if) to fix the mismatched behavior in `DatetimeIndex.__add__` and `__sub__`

```
rng = pd.date_range('2000-01-01 09:00', freq='H', periods=2, tz='US/Pacific')
ser = pd.Series(rng)
other = np.array(1, dtype=np.int64)

>>> ser + other
[...]
TypeError: incompatible type for a datetime/timedelta operation [__add__]

>>> rng + other
DatetimeIndex(['2000-01-01 17:00:00.000000001-08:00', '2000-01-01 18:00:00.000000001-08:00'], dtype='datetime64[ns, US/Pacific]', freq=None)

>>> other + rng
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'numpy.ndarray' and 'DatetimeIndex'
```

This PR addressed that [here](https://github.com/pandas-dev/pandas/pull/18817/files#diff-26a6d2ca7adfca586aabbb1c9dd8bf36R673) and  [here](https://github.com/pandas-dev/pandas/pull/18817/files#diff-26a6d2ca7adfca586aabbb1c9dd8bf36R710), but got some pushback because it was (admittedly) ugly.  Alternative suggestions requested.

Closing this PR, will (eventually) open another one with reduced scope.