Skip to content

BUG: groupby(Grouper) with all-NaT grouping keys #43486

Open
@jbrockmendel

Description

@jbrockmendel

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDatetimeDatetime data dtypeGroupbyMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions