-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
import pandas as pd
df = pd.DataFrame({"date": [pd.NaT], "value": [11]})
grouper = pd.Grouper(freq="M", key="date")
>>> gb = df.groupby(grouper)
[...]
File "pandas/core/resample.py", line 1878, in _get_timestamp_range_edges
first = first.normalize()
AttributeError: 'NaTType' object has no attribute 'normalize'
### Issue Description
Example derived from test_timegrouper_apply_return_type_series
### Expected Behavior
Either not raise or raise at construction of the Grouper object with a useful exception message.
### Installed Versions
master
**Comment From: WKKO**
Sorry to bother you. Do you know the solution to this problem? I've been in trouble recently
**Comment From: burnpanck**
I believe this is a manifestation of #24983: With the current design, `pd.NaT` isn't a timestamp at all; it ambiguously refers to either an undefined timedelta or an undefined timestamp. You might get lucky by explicitly making the `"date"` column a timestamp, but the grouper might nonetheless fail once it reaches the nat time.
**Comment From: jamsden**
Any workaround identified? i.e., could I test for all NaT values and return an empty Series?
**Comment From: kfchou**
Since it wouldn't make sense to count or add anything in this situation, here's my workaround:
if all(df['key'].isna()):
df['key'] = pd.DataFrame(columns=df.columns)
```