TST: Test resampling with NaT
State: closed

- Closes #13020
- Adds `test_generic.py:TestDataFrame.test_resample_with_nat`
- Passes tests and flake8
- No documentation needed


Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
name: Resample
description: resample method

Comments:
Thanks. Can you also add `TimedeltaIndex` and `PeriodIndex`?

## [Current coverage](https://codecov.io/gh/pydata/pandas/pull/13164?src=pr) is **84.12%**

> Merging [#13164](https://codecov.io/gh/pydata/pandas/pull/13164?src=pr) into [master](https://codecov.io/gh/pydata/pandas/branch/master?src=pr) will decrease coverage by **<.01%**

``` diff
@@             master     #13164   diff @@
==========================================
  Files           138        138          
  Lines         50388      50380     -8   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          42386      42379     -7   
+ Misses         8002       8001     -1   
  Partials          0          0          
```
1. 2 files (not in diff) in `pandas/tseries` were modified. [more](https://codecov.io/gh/pydata/pandas/commit/6d47c874a19498201b708e878d66c4126671b2bd/changes?src=pr#70616E6461732F74736572696573) 
   - Misses `+1` 
   - Hits `-2`
2. 2 files (not in diff) in `pandas/tools` were modified. [more](https://codecov.io/gh/pydata/pandas/commit/6d47c874a19498201b708e878d66c4126671b2bd/changes?src=pr#70616E6461732F746F6F6C73) 
   - Hits `-4`
3. 4 files (not in diff) in `pandas` were modified. [more](https://codecov.io/gh/pydata/pandas/commit/6d47c874a19498201b708e878d66c4126671b2bd/changes?src=pr#70616E646173) 
   - Misses `-2` 
   - Hits `-1`

> Powered by [Codecov](https://codecov.io?src=pr). Last updated by [4e4a7d9...6d47c87](https://codecov.io/gh/pydata/pandas/compare/4e4a7d9ae5b3c05b21dc0a0f3c12648236ec586e...6d47c874a19498201b708e878d66c4126671b2bd)

@evectant can you rebase & update

@sinhrks Those don't seem to be very tolerant to `NaT`. I'm not sure what behavior we should pin down here.

```
In [2]: dti = pd.DatetimeIndex(['1970-01-01 00:00:00', pd.NaT, '1970-01-01 00:00:02'])

In [3]: pd.DataFrame([2, 3, 5], dti).resample('1s').mean()
Out[3]: 
                       0
1970-01-01 00:00:00  2.0
1970-01-01 00:00:01  NaN
1970-01-01 00:00:02  5.0
```

```
In [4]: tdi = pd.to_timedelta(['0s', pd.NaT, '2s'])

In [5]: pd.DataFrame([2, 3, 5], tdi).resample('1s').mean()
...
MemoryError:
```

```
In [6]: pi = pd.PeriodIndex(['1970-01-01 00:00:00', pd.NaT, '1970-01-01 00:00:02'], freq='S')

In [7]: pd.DataFrame([2, 3, 5], pi).resample('1s').mean()
...
ValueError: Start and end must not be NaT
```

@evectant Thx to confirm. It's gr8 if you can fix, otherwise keep #13020 open or submit new issue for tracking.

@sinhrks @jreback I think there are three different issues here:
- Resampling with `NaT` in `DatetimeIndex` raises `ValueError` (fixed in master, pinned down here)
- Resampling with `NaT` in `TimedeltaIndex` raises `MemoryError` (entered #13223, will look into)
- Resampling with `NaT` in `PeriodIndex` raises `ValueError` (entered #13224, will look into)

So can this one be merged and #13020 closed?

thanks @evectant 

merged.

when you work on the other too resample-with-nat issues, ideally we move this test to `Base` (so it cycles thru all index types); then these are all in 1 place.