-
-
Notifications
You must be signed in to change notification settings - Fork 147
Closed
Labels
Description
Describe the bug
In this line:
def rolling(self, *args, **kwargs): ... |
we are not returning a Rolling
object with the proper subtype of Series
or DataFrame
To Reproduce
from typing_extensions import reveal_type
import pandas as pd
df = pd.DataFrame(
{"A": [1, 1, 2, 2], "B": [1, 2, 3, 4], "C": [0.362, 0.227, 1.267, -0.562]}
)
d1 = df.groupby("A").rolling(2).sum()
s1 = df.groupby("A")["B"].rolling(2).sum()
s2 = df.groupby("A").rolling(2)["B"].sum()
reveal_type(d1)
reveal_type(s1)
reveal_type(s2)
at runtime produces
Runtime type is 'DataFrame'
Runtime type is 'Series'
Runtime type is 'Series'
but pyright produces
grbroll.py:14:13 - information: Type of "d1" is "Unknown"
grbroll.py:16:13 - information: Type of "s1" is "Unknown"
grbroll.py:18:13 - information: Type of "s2" is "Unknown"
Please complete the following information:
- OS: Windows 10
- python version: 3.9
- version of type checker: pyright 1.1.313
- version of installed
pandas-stubs
: 2.0.2.230605
Additional context
This will need some care to make sure that the types are done correctly. May have to move the def rolling
from pandas-stubs/core/groupby/groupby.pyi
to pandas-stubs/core/groupby/generic.pyi
in DataFrameGroupby
and SeriesGroupBy
.