BUG/TST/REF: Datetimelike Arithmetic Methods
@TomAugspurger @jorisvandenbossche @jreback as discussed

- [ ] closes #xxxx
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

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

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

```diff
@@            Coverage Diff             @@
##           master   #23215      +/-   ##
==========================================
- Coverage   92.16%   92.16%   -0.01%     
==========================================
  Files         166      166              
  Lines       51224    51206      -18     
==========================================
- Hits        47212    47192      -20     
- Misses       4012     4014       +2
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.59% <95%> (-0.01%)` | :arrow_down: |
| #single | `42.24% <21.66%> (+0.01%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23215?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/23215/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `94.01% <100%> (+0.79%)` | :arrow_up: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/23215/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `94.3% <100%> (-0.18%)` | :arrow_down: |
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/23215/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `90.62% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23215/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `91.04% <84.21%> (-1.19%)` | :arrow_down: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23215/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `97.48% <93.54%> (-0.09%)` | :arrow_down: |
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/23215/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `97.9% <96%> (+0.39%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23215?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/23215?src=pr&el=footer). Last update [62a15fa...0466b9c](https://codecov.io/gh/pandas-dev/pandas/pull/23215?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 Hello @jbrockmendel! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/core/arrays/datetimelike.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/core/arrays/datetimelike.py) !

 - There are no PEP8 issues in the file [`pandas/core/arrays/datetimes.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/core/arrays/datetimes.py) !

 - There are no PEP8 issues in the file [`pandas/core/arrays/period.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/core/arrays/period.py) !

 - There are no PEP8 issues in the file [`pandas/core/arrays/timedeltas.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/core/arrays/timedeltas.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arithmetic/test_period.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/tests/arithmetic/test_period.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arithmetic/test_timedelta64.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/tests/arithmetic/test_timedelta64.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/datetimes/test_ops.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/tests/indexes/datetimes/test_ops.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/period/test_ops.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/tests/indexes/period/test_ops.py) !

 - There are no PEP8 issues in the file [`pandas/tests/indexes/timedeltas/test_ops.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/tests/indexes/timedeltas/test_ops.py) !

 - There are no PEP8 issues in the file [`pandas/util/testing.py`](https://github.com/jbrockmendel/pandas/blob/8a7c2495fc343f7531cf3c94297d3e91952ddfcc/pandas/util/testing.py) !

 - Complete extra results for this file :

> file_to_check.py:2522:-258: W605 invalid escape sequence '\('
file_to_check.py:2522:-255: W605 invalid escape sequence '\)'
---

 @datapythonista where should I be looking for the explanation of why the linting is failing?  It used to tell me right above the "exited wth code 1" line

From Travis log:

```
============== 4 passed, 4 deselected, 1 warnings in 0.24 seconds ==============
Doctests top-level reshaping functions DONE
The command "ci/code_checks.sh" exited with 1.
``` https://travis-ci.org/pandas-dev/pandas/jobs/443307753#L2918

I search for `ci/code_checks.sh`. We should be passing a `-q` to the doctests I think. It's the imports I think?

```
Check import format using isort
ERROR: /home/travis/build/pandas-dev/pandas/pandas/core/indexes/range.py Imports are incorrectly sorted.
Check import format using isort DONE
``` > It's the imports I think?

Yah, I think #23231 should have just fixed it.  I'll re-push in a bit.
 Updated with additional bugfixes:
- DateOffset + (PeriodIndex|DataFrame) no longer raises TypeError
- PeriodIndex[freq.n!=1] + DateOffset is no longer incorrect Ok.

On Fri, Oct 19, 2018 at 11:45 AM jbrockmendel <notifications@github.com>
wrote:

> *@jbrockmendel* commented on this pull request.
> ------------------------------
>
> In pandas/core/arrays/period.py
> <https://github.com/pandas-dev/pandas/pull/23215#discussion_r226711521>:
>
> > @@ -379,38 +378,18 @@ def _add_delta_tdi(self, other):
>          delta = self._check_timedeltalike_freq_compat(other)
>          return self._addsub_int_array(delta, operator.add)
>
> +    @Appender(DatetimeLikeArrayMixin._add_delta.__doc__)
>
> I usually print the docstring, mostly because I usually forget about the
> other usages. This is an internal method so it doesn't *really* matter.
> My view ATM is just that its zero-cost.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/23215#discussion_r226711521>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHItBl-leUdaB1K4k7JLwg0wnj18O4ks5umgG8gaJpZM4XrJDW>
> .
>
 @jorisvandenbossche w/r/t docstrings: will do.

w/r/t the tz_convert: good catch.  Will fix, and make a test.


 Updated to move the overriding of `add_sub_int_array` to `PeriodArray` > Updated to move the overriding of add_sub_int_array to PeriodArray

I don't think it helps moving this here. This only makes it much harder for Tom to update this PR if we merge this one first. > I don't think it helps moving this here. This only makes it much harder for Tom to update this PR if we merge this one first.

As I mentioned in the PeriodArray PR, arithmetic refactoring should be consolidated here.  If Tom disagrees, I'll revert. > As I mentioned in the PeriodArray PR, arithmetic refactoring should be consolidated here. If Tom disagrees, I'll revert.

The change is rather orthogonal to the other changes in this PR, IMO. But anyway, I don't care where it is done in practice, so @TomAugspurger 's call. No preference on the order. I won't have time to update the PeriodArray PR till Wednesday. OK, then let's keep it here (and merge this first) needs a rebase Spurious test failures notwithstanding, are there any outstanding issues left here? Rebased following PeriodArray one more rebase ping on green @jorisvandenbossche anything else to address or can i ping jeff? will look tonight  Ping thanks @jbrockmendel 