Create ABCDateOffset
State: closed

`DateOffset` is one of a small number of commonly-used classes for which no `ABCFoo` class exists.  Putting this in place is cheap and gives us an option to use it down the road.

Replaced `isinstance(x, DateOffset)` with `isinstance(x, ABCDateOffset)` in a few places where doing so lets us avoid run-time imports.  Other than that this holds off on actually _using_ `ABCDateOffset`, as the `ABCFoo` isinstance checks do appear to be appreciably slower than the non-ABC versions.

 - [ ] closes #xxxx
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master -u -- "*.py" | flake8 --diff``
 - [ ] whatsnew entry


Labels:
name: Enhancement
name: Dtype Conversions
description: Unexpected or buggy dtype conversions

Comments:
@jbrockmendel : Good start here.  Needs a `whatsnew` + some testing (we have tests for checking the `ABC*`)
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=h1) Report
> Merging [#17165](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/0c4bc059d7a99b66f0f5251d699a753c9fe81ced?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/17165/graphs/tree.svg?height=150&width=650&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #17165      +/-   ##
==========================================
+ Coverage   90.99%      91%   +<.01%     
==========================================
  Files         162      162              
  Lines       49499    49498       -1     
==========================================
+ Hits        45043    45045       +2     
+ Misses       4456     4453       -3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.78% <100%> (+0.02%)` | :arrow_up: |
| #single | `40.26% <100%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `97.13% <100%> (ø)` | :arrow_up: |
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `91.86% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `95.93% <100%> (-0.01%)` | :arrow_down: |
| [pandas/core/dtypes/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2dlbmVyaWMucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/core/tools/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvZGF0ZXRpbWVzLnB5) | `66.85% <100%> (-0.1%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.66% <0%> (-0.1%)` | :arrow_down: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.05% <0%> (+1.81%)` | :arrow_up: |

------

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

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=h1) Report
> Merging [#17165](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/7bef6d873b8af5ee0d35ba4b42c8a4775a6b3f24?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #17165      +/-   ##
==========================================
- Coverage      91%   90.98%   -0.02%     
==========================================
  Files         162      162              
  Lines       49508    49507       -1     
==========================================
- Hits        45055    45045      -10     
- Misses       4453     4462       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.76% <100%> (-0.01%)` | :arrow_down: |
| #single | `40.26% <100%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `91.86% <100%> (ø)` | :arrow_up: |
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `97.13% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `95.93% <100%> (-0.01%)` | :arrow_down: |
| [pandas/core/dtypes/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2dlbmVyaWMucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/core/tools/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvZGF0ZXRpbWVzLnB5) | `66.85% <100%> (-0.1%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17165?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.71% <0%> (-0.1%)` | :arrow_down: |

------

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

> Good start here. Needs a whatsnew + some testing (we have tests for checking the ABC*)

only the tests for the ABC are necessary. this is purely internal and doesn't require a whatsnew.

there *might* be a couple of places that you can use this in cython as well (in the .pyx).
Just pushed a commit with added tests.

> there might be a couple of places that you can use this in cython as well (in the .pyx).

Looks like it gets checked in period.pyx.  `_libs.period` already imports `tseries.frequencies` (which imports `tseries.offsets`), so replacing `DateOffset` with `ABCDateOffset` there wouldn't simplify the import structure.  That said, the downside is minimal if someone has a strong preference.

Related: for kicks I tried implementing `ABCDateOffset` in cython and found it made a non-trivial (relative) difference.  Instead of `isinstance(item, ABCDateOffset)` taking 2x as long as `isinstance(item, DateOffset)`, its closer to 1.1x.  
this looks fine. needs a rebase.
thanks!