BUG: Fix IntervalTree handling of NaN
State: closed

- [X] closes #23352
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [X] whatsnew entry

xref #23327 : As far as I can tell the only reason that PR is failing is because of tests raising a `RuntimeWarning` due to this bug.


Labels:
name: Bug
name: Interval
description: Interval data type

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

 - There are no PEP8 issues in the file [`pandas/tests/indexes/interval/test_interval_tree.py`](https://github.com/jschendel/pandas/blob/4f13207a6fb468f48565363d67cfd0c1e5a4aada/pandas/tests/indexes/interval/test_interval_tree.py) !


Does this apply to `NaT` as well?
> Does this apply to NaT as well?

`IntervalIndex` performs an i8 conversion on datetime/timedelta data prior to passing it to `IntervalTree`, as `IntervalTree` only supports numeric dtypes, so only need to worry about `np.nan` in `IntervalTree`.  As part of the i8 conversion `NaT` is explicitly converted to `np.nan` instead of `NaT`'s integer value (implemented in #23327 but could maybe be moved here), as it's integer value can be mistakenly interpreted as non-null data once everything's been converted to integers.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23353?src=pr&el=h1) Report
> Merging [#23353](https://codecov.io/gh/pandas-dev/pandas/pull/23353?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/437f31cb609372f465aaa853bf4b2299a9550716?src=pr&el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #23353      +/-   ##
==========================================
- Coverage   92.22%   92.18%   -0.05%     
==========================================
  Files         169      161       -8     
  Lines       51258    51160      -98     
==========================================
- Hits        47274    47161     -113     
- Misses       3984     3999      +15
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.61% <ø> (-0.05%)` | :arrow_down: |
| #single | `42.24% <ø> (+0.01%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23353?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/\_depr\_module.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX2RlcHJfbW9kdWxlLnB5) | `0% <0%> (-65.12%)` | :arrow_down: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `91.04% <0%> (-1.24%)` | :arrow_down: |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `94.37% <0%> (-0.49%)` | :arrow_down: |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `88.92% <0%> (-0.31%)` | :arrow_down: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `94.3% <0%> (-0.18%)` | :arrow_down: |
| [pandas/core/nanops.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbmFub3BzLnB5) | `95.05% <0%> (-0.15%)` | :arrow_down: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `97.48% <0%> (-0.09%)` | :arrow_down: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `93.89% <0%> (-0.03%)` | :arrow_down: |
| [pandas/io/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3B5dGFibGVzLnB5) | `92.43% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.79% <0%> (-0.01%)` | :arrow_down: |
| ... and [21 more](https://codecov.io/gh/pandas-dev/pandas/pull/23353/diff?src=pr&el=tree-more) | |

------

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

this broke 32 bit builds
https://travis-ci.org/MacPython/pandas-wheels/jobs/448674095

can u have a look @jschendel 
@jreback : it looks like this 32 bit failure is something that's come up before and is currently explicitly skipped in the other test where it occurs:

https://github.com/pandas-dev/pandas/blob/de39bfc5e5c6483cb2669773fa10ddc2e32ca111/pandas/tests/indexes/interval/test_interval_tree.py#L88-L91

This was done before my time, so not sure about the exact history here.

My plan is to similarly skip the newly written tests and open a relevant issue to formally document this.  It doesn't seem particularly pressing to fix since this has been present for a while, only impacts 32 bit, and there haven't been any issues opened.  Can look into fixing it if I'm mistaken, though I don't immediately see what needs to be done.