Skip to content

Return type from pandas.core.groupby.generic.DataFrameGroupBy.resample #825

Closed
@vectro

Description

@vectro

Describe the bug
The type hint for pandas.core.groupby.generic.DataFrameGroupBy.resample says it returns a pandas.core.groupby.grouper.Grouper; however in at least some situations this function can return a pandas.core.resample.DatetimeIndexResamplerGroupby, which is not a Grouper.

To Reproduce
This results in a false positive on MyPy 1.7.1:

df.set_index("date").groupby("intensity").resample("90D")["duration"]

The error message is

error: Value of type "Grouper" is not indexable  [index]

Please complete the following information:
Python 3.11
Mypy 1.7.1
pandas-stubs 2.1.1.230928

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions