[WIP] ENH: interval accessor
State: closed

- [ ] closes #16401
- [ ] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Still have a quite a few things to do, but wanted to make sure I'm on the right track, and have this PR in place to motivate any additional issues/PR that need to be done as a prereq for this.

TODO:
- Add `IntervalIndex` methods to the accessor
   - I don't immediately see any existing methods that are appropriate for this
   - There are a few open issues/PR related to methods that could be appropriate here
- Documentation
   - whatsnew entry
   - Add a section to the main docs (top level?) with examples (xref #16400)
- More tests
  - Tests for  `IntervalIndex` methods once they've been added
  - Anything else I'm missing?

Example usage:
```python
In [2]: s = pd.Series(pd.IntervalIndex.from_breaks([0, 1, 3, 6, 10]))

In [3]: s
Out[3]:
0     (0, 1]
1     (1, 3]
2     (3, 6]
3    (6, 10]
dtype: object

In [4]: s.iv.length
Out[4]:
0    1
1    2
2    3
3    4
dtype: int64

In [5]: s.iv.mid
Out[5]:
0    0.5
1    2.0
2    4.5
3    8.0
dtype: float64
```

cc @TomAugspurger : thought you'd be interested as this relates to the new extension accessor code

Labels:
name: API Design
name: Interval
description: Interval data type

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

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

```diff
@@            Coverage Diff             @@
##           master   #19502      +/-   ##
==========================================
- Coverage   91.67%   91.66%   -0.02%     
==========================================
  Files         148      148              
  Lines       48553    48610      +57     
==========================================
+ Hits        44513    44558      +45     
- Misses       4040     4052      +12
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.03% <77.96%> (-0.02%)` | :arrow_down: |
| #single | `41.82% <27.11%> (+0.1%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/19502?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/19502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9pbnRlcnZhbC5weQ==) | `92.41% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/19502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `94.6% <100%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/19502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `94.9% <66.66%> (-0.42%)` | :arrow_down: |
| [pandas/core/indexes/accessors.py](https://codecov.io/gh/pandas-dev/pandas/pull/19502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9hY2Nlc3NvcnMucHk=) | `86% <77.08%> (-4.2%)` | :arrow_down: |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/19502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `88.15% <0%> (+0.16%)` | :arrow_up: |

------

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

Looks good to me (I wonder if any bits can be put into `PandasDelegate`, and shared between subclasses?)

What do people think about the name `.iv`, versus the longer `.interval`?
should be interval i think
I prefer interval too.

On Sat, Feb 3, 2018 at 8:58 PM, Jeff Reback <notifications@github.com>
wrote:

> should be interval i think
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/19502#issuecomment-362853828>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIkXG9YrU5vB0Gyhd_nUHNRUDfmttks5tRMiLgaJpZM4R2kjN>
> .
>

FWIW my choice of using an abbreviated name was that it seems more consistent with the existing accessor naming conventions; we use `.str` instead of `.string`, and likewise for `.cat` and `.dt`.  Another option is `.itv`, but willing to go with `.interval` if that's the consensus.
@jschendel happy to have this. if you can close for now, or update
closing as stale for now, happy to have this when you have time @jschendel