ENH: Implement overlaps method for Interval-like
State: closed

- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [X] whatsnew entry
- xref #21998, #18975

Implements `Interval.overlaps`, `IntervalArray.overlaps`, and `IntervalIndex.overlaps`.

Implementing this so there's an interval method that can be tested in the interval accessor PR (#19502), as there are currently only attributes that can be used by the accessor. Planning to reboot that PR soon after this is merged.

I didn't implement `IntervalArray.overlaps(IntervalArray)`; the PR providing the specs for `overlaps` was recently closed due to being stale, and I don't recall there being a resolution on this behavior.



Labels:
name: Enhancement
name: Interval
description: Interval data type

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

 - There are no PEP8 issues in the file [`pandas/conftest.py`](https://github.com/jschendel/pandas/blob/2d240f2584086189c0ad9e5297cdd74ce5efe0e4/pandas/conftest.py) !

 - There are no PEP8 issues in the file [`pandas/core/arrays/interval.py`](https://github.com/jschendel/pandas/blob/2d240f2584086189c0ad9e5297cdd74ce5efe0e4/pandas/core/arrays/interval.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/interval.py`](https://github.com/jschendel/pandas/blob/2d240f2584086189c0ad9e5297cdd74ce5efe0e4/pandas/core/indexes/interval.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arrays/interval/test_interval_ops.py`](https://github.com/jschendel/pandas/blob/2d240f2584086189c0ad9e5297cdd74ce5efe0e4/pandas/tests/arrays/interval/test_interval_ops.py) !

 - There are no PEP8 issues in the file [`pandas/tests/scalar/interval/test_interval_ops.py`](https://github.com/jschendel/pandas/blob/2d240f2584086189c0ad9e5297cdd74ce5efe0e4/pandas/tests/scalar/interval/test_interval_ops.py) !



##### Comment last updated on October 02, 2018 at 03:16 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22939?src=pr&el=h1) Report
> Merging [#22939](https://codecov.io/gh/pandas-dev/pandas/pull/22939?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5ce06b5bdb8c44043c6463bf8ce3da758800a189?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `93.33%`.

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

```diff
@@            Coverage Diff             @@
##           master   #22939      +/-   ##
==========================================
+ Coverage   92.19%   92.19%   +<.01%     
==========================================
  Files         169      169              
  Lines       50833    50966     +133     
==========================================
+ Hits        46863    46987     +124     
- Misses       3970     3979       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.61% <93.33%> (ø)` | :arrow_up: |
| #single | `42.27% <40%> (-0.1%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22939?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2ludGVydmFsLnB5) | `93.02% <100%> (+0.46%)` | :arrow_up: |
| [pandas/core/indexes/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9pbnRlcnZhbC5weQ==) | `94.65% <80%> (+0.49%)` | :arrow_up: |
| [pandas/plotting/\_compat.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb21wYXQucHk=) | `87.5% <0%> (-3.81%)` | :arrow_down: |
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `94.63% <0%> (-2.74%)` | :arrow_down: |
| [pandas/compat/numpy/function.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9udW1weS9mdW5jdGlvbi5weQ==) | `86.66% <0%> (-1.82%)` | :arrow_down: |
| [pandas/core/internals/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2NvbmNhdC5weQ==) | `96.83% <0%> (-1.54%)` | :arrow_down: |
| [pandas/core/dtypes/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbmNhdC5weQ==) | `97.69% <0%> (-1.49%)` | :arrow_down: |
| [pandas/compat/numpy/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9udW1weS9fX2luaXRfXy5weQ==) | `92.85% <0%> (-1.09%)` | :arrow_down: |
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `92.91% <0%> (-0.95%)` | :arrow_down: |
| [pandas/core/internals/managers.py](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL21hbmFnZXJzLnB5) | `95.77% <0%> (-0.9%)` | :arrow_down: |
| ... and [60 more](https://codecov.io/gh/pandas-dev/pandas/pull/22939/diff?src=pr&el=tree-more) | |

------

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

Created a common mixin class for the tests:
- Put the mixin class in `tests/arrays/interval/interval_ops.py`
  - Not sure that this is the best location; any better alternatives?
  - Kind of gross import in the `indexes` tests: `from ...arrays.interval.interval_ops`
- Created `test_interval_ops.py` files in both the `indexes` and `arrays` subfolders that use the mixin.
lgtm. if you have any other comments @jorisvandenbossche or @TomAugspurger otherwise merge away.
ping @jorisvandenbossche @TomAugspurger : I'm planning to merge this within the next couple days so I can have a method to test out in the interval accessor PR.  Just wanted to give both of you a quick heads up in case either of you wanted to review prior to this getting merged.  The interval accessor PR has some merge conflicts that need to be resolved, so no immediate rush, but I'm planning to address the conflicts soon.
thanks @jschendel pls follow up as needed.