Implement integer array add/sub for datetimelike indexes
State: closed

AFAICT this is the next-to-last non-raising case for these operations.  After this is just object-dtype, and for that we already have the correct implementation in addsub_offset_array, just need to make the condition less strict and add appropriate tests.

- [ ] closes #xxxx
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Datetime
description: Datetime data dtype
name: Timedelta
description: Timedelta data type
name: Period
description: Period data type
name: Compat
description: pandas objects compatability with Numpy or Python functions

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/19959?src=pr&el=h1) Report
> Merging [#19959](https://codecov.io/gh/pandas-dev/pandas/pull/19959?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/cc8d33e00bcf7d1e0bf08f58ffae3f16d37ff118?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #19959      +/-   ##
==========================================
+ Coverage   91.83%   91.84%   +<.01%     
==========================================
  Files         153      153              
  Lines       49498    49515      +17     
==========================================
+ Hits        45458    45475      +17     
  Misses       4040     4040
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.23% <100%> (ø)` | :arrow_up: |
| #single | `41.87% <8.69%> (-0.02%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/19959?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/19959/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `96.89% <100%> (+0.09%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/19959?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/19959?src=pr&el=footer). Last update [cc8d33e...6cb1b43](https://codecov.io/gh/pandas-dev/pandas/pull/19959?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Comments above acknowledged.

Let's stick a pin in this for a little bit.  I think there may be a problem with integer ops, need to double-check before moving forward on this.
> Let's stick a pin in this for a little bit. I think there may be a problem with integer ops, need to double-check before moving forward on this.

I've convinced myself this is OK.  Or more accurately, that weird behavior (not affected by this PR, but in integer add/sub) can only come up if a user specifically passes `verify_integrity=False` to `DatetimeIndex` or `TimedeltaIndex`.
Needs rebasing since its gotten a bit stale, but I think this is otherwise ready.  Will push shortly.
@jreback gentle ping
rebase as well
@jreback gentle ping.  I've got some time this weekend I can put towards finishing this off.
@gfyoung any idea if everything/everyone is OK?
@jbrockmendel : I see a bunch of comments from @jreback that you haven't **explicitly** addressed.  That might be why no one is saying anything.
@gfyoung Thanks.  I think there's just the one where I haven't un-indented an `else:` clause as requested; might as well do that now.  I think the others are addressed, though some are indirect.
> I think the others are addressed, though some are indirect.

<strike>Did you address the commenting request <a href="https://github.com/pandas-dev/pandas/pull/19959#discussion_r172854111">above</a>?</strike>

EDIT: I see the comment now! 😄 
@jreback : ping.  I think all comments have been addressed.
@jreback gentle ping.  I'd like to finish this off and get back to unifying Index/Series/DataFrame arithmetic implementations in `core.ops`.
will have to wait until after the rc
@jreback gentle ping
@jreback if we can get this through then DatetimeIndex + IntArray will be meaningful and we can flesh out the tests in #21160.
thanks @jbrockmendel 

it seems there might be some code you can remove from PeriodIndex though? (obviously in a followup)
> it seems there might be some code you can remove from PeriodIndex though? 

Sounds plausible; I'll have to refresh my memory.  IIRC the next dtype to handle is Period/PeriodIndex subtraction, with the complication that we need to fix the current scalar subtraction behavior.