ENH: support NaT values into datetime series for interpolation (#11701)
State: closed

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


Labels:
name: Enhancement
name: Datetime
description: Datetime data dtype
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments:
Glad this is getting fixed, good work.  Want to handle the time delta case while you’re at it?
@jbrockmendel - Are you referring to https://github.com/pandas-dev/pandas/issues/19199 ?
#19199 is also about datetime64.  I'm not sure if there is a separate issue for `timedelta64[ns]`, but the behavior is the same.
Okay. I will take a look at both #19199 and timedelta64[ns]
@atulaggarwal needs rebase.  We can try to push this through as is, or aim for the cleaner long-term solution of implementing interpolate on DatetimeArray and TimedeltaArray.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21851?src=pr&el=h1) Report
> Merging [#21851](https://codecov.io/gh/pandas-dev/pandas/pull/21851?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/4f11d1a9a9b02a37dbe109d8413cc75d73b92853?src=pr&el=desc) will **decrease** coverage by `0.13%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #21851      +/-   ##
==========================================
- Coverage   92.05%   91.91%   -0.14%     
==========================================
  Files         169      164       -5     
  Lines       50733    49998     -735     
==========================================
- Hits        46702    45958     -744     
- Misses       4031     4040       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.3% <100%> (-0.16%)` | :arrow_down: |
| #single | `42.15% <0%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/21851?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.47% <100%> (+0.03%)` | :arrow_up: |
| [pandas/util/\_doctools.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX2RvY3Rvb2xzLnB5) | `0% <0%> (-12.88%)` | :arrow_down: |
| [pandas/core/reshape/util.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS91dGlsLnB5) | `90.32% <0%> (-9.68%)` | :arrow_down: |
| [pandas/util/\_decorators.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX2RlY29yYXRvcnMucHk=) | `82.25% <0%> (-9.09%)` | :arrow_down: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `92.19% <0%> (-5.15%)` | :arrow_down: |
| [pandas/tseries/frequencies.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvZnJlcXVlbmNpZXMucHk=) | `95.9% <0%> (-1.18%)` | :arrow_down: |
| [pandas/core/indexes/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9pbnRlcnZhbC5weQ==) | `93.18% <0%> (-0.98%)` | :arrow_down: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `96.94% <0%> (-0.83%)` | :arrow_down: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `63.2% <0%> (-0.69%)` | :arrow_down: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `91.35% <0%> (-0.64%)` | :arrow_down: |
| ... and [71 more](https://codecov.io/gh/pandas-dev/pandas/pull/21851/diff?src=pr&el=tree-more) | |

------

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

@jbrockmendel - Updated PR with latest master. I would suggest merging it as is. I will work on working on other items too (but lets not block on them) as current PR solves one of the problem. What do you suggest?
> I would suggest merging it as is.

As jreback mentioned, the implementation is not in the right place.  The viable options are in `core.internals.blocks.DatetimeLikeBlockMixin` and `core.arrays.datetimelike.DatetimeLikeArrayMixin`
I think this might give incorrect answers for values near the int64 bounds because casting to float will be lossy.  Can you add a test for that?
closing as stale. if you'd like to continue, pls ping.