Skip to content

Commit da3e116

Browse files
Kevin Sheppardbashtage
Kevin Sheppard
authored andcommitted
ENH: Add generic
1 parent eeeb61b commit da3e116

File tree

6 files changed

+72
-71
lines changed

6 files changed

+72
-71
lines changed

pandas-stubs/core/frame.pyi

+4-4
Original file line numberDiff line numberDiff line change
@@ -1416,13 +1416,13 @@ class DataFrame(NDFrame, OpsMixin):
14161416
adjust: _bool = ...,
14171417
ignore_na: _bool = ...,
14181418
axis: AxisType = ...,
1419-
) -> ExponentialMovingWindow: ...
1419+
) -> ExponentialMovingWindow[DataFrame]: ...
14201420
def expanding(
14211421
self,
14221422
min_periods: int = ...,
14231423
axis: AxisType = ...,
14241424
method: Literal["single", "table"] = ...,
1425-
) -> Expanding: ...
1425+
) -> Expanding[DataFrame]: ...
14261426
@overload
14271427
def ffill(
14281428
self,
@@ -1779,7 +1779,7 @@ class DataFrame(NDFrame, OpsMixin):
17791779
on: _str | None = ...,
17801780
axis: AxisType = ...,
17811781
closed: _str | None = ...,
1782-
) -> Window: ...
1782+
) -> Window[DataFrame]: ...
17831783
@overload
17841784
def rolling(
17851785
self,
@@ -1790,7 +1790,7 @@ class DataFrame(NDFrame, OpsMixin):
17901790
on: _str | None = ...,
17911791
axis: AxisType = ...,
17921792
closed: _str | None = ...,
1793-
) -> Rolling: ...
1793+
) -> Rolling[DataFrame]: ...
17941794
def rpow(
17951795
self,
17961796
other,

pandas-stubs/core/series.pyi

+4-4
Original file line numberDiff line numberDiff line change
@@ -1323,13 +1323,13 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
13231323
adjust: _bool = ...,
13241324
ignore_na: _bool = ...,
13251325
axis: SeriesAxisType = ...,
1326-
) -> ExponentialMovingWindow: ...
1326+
) -> ExponentialMovingWindow[Series]: ...
13271327
def expanding(
13281328
self,
13291329
min_periods: int = ...,
13301330
axis: SeriesAxisType = ...,
13311331
method: Literal["single", "table"] = ...,
1332-
) -> Expanding: ...
1332+
) -> Expanding[Series]: ...
13331333
def floordiv(
13341334
self,
13351335
other: num | _ListLike | Series[S1],
@@ -1532,7 +1532,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
15321532
on: _str | None = ...,
15331533
axis: SeriesAxisType = ...,
15341534
closed: _str | None = ...,
1535-
) -> Window: ...
1535+
) -> Window[Series]: ...
15361536
@overload
15371537
def rolling(
15381538
self,
@@ -1543,7 +1543,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
15431543
on: _str | None = ...,
15441544
axis: SeriesAxisType = ...,
15451545
closed: _str | None = ...,
1546-
) -> Rolling: ...
1546+
) -> Rolling[Series]: ...
15471547
def rpow(
15481548
self,
15491549
other: Series[S1] | Scalar,

pandas-stubs/core/window/ewm.pyi

+10-9
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ from pandas.core.window.rolling import BaseWindow
1010

1111
from pandas._typing import (
1212
Axis,
13+
NDFrameT,
1314
TimedeltaConvertibleTypes,
1415
)
1516

16-
class ExponentialMovingWindow(BaseWindow):
17+
class ExponentialMovingWindow(BaseWindow[NDFrameT]):
1718
com: Any = ... # Incomplete
1819
span: Any = ... # Incomplete
1920
halflife: Any = ... # Incomplete
@@ -23,7 +24,7 @@ class ExponentialMovingWindow(BaseWindow):
2324
times: Any = ... # Incomplete
2425
def __init__(
2526
self,
26-
obj: NDFrame,
27+
obj: NDFrameT,
2728
com: float | None = ...,
2829
span: float | None = ...,
2930
halflife: float | TimedeltaConvertibleTypes | None = ...,
@@ -46,27 +47,27 @@ class ExponentialMovingWindow(BaseWindow):
4647
engine: Any | None = ...,
4748
engine_kwargs: Any | None = ...,
4849
**kwargs,
49-
) -> Series | DataFrame: ...
50+
) -> NDFrameT: ...
5051
def sum(
5152
self,
5253
*args,
5354
engine: Any | None = ...,
5455
engine_kwargs: Any | None = ...,
5556
**kwargs,
56-
) -> Series | DataFrame: ...
57-
def std(self, bias: bool = ..., *args, **kwargs) -> Series | DataFrame: ...
58-
def vol(self, bias: bool = ..., *args, **kwargs) -> Series | DataFrame: ...
59-
def var(self, bias: bool = ..., *args, **kwargs) -> Series | DataFrame: ...
57+
) -> NDFrameT: ...
58+
def std(self, bias: bool = ..., *args, **kwargs) -> NDFrameT: ...
59+
def vol(self, bias: bool = ..., *args, **kwargs) -> NDFrameT: ...
60+
def var(self, bias: bool = ..., *args, **kwargs) -> NDFrameT: ...
6061
def cov(
6162
self,
6263
other: DataFrame | Series | None = ...,
6364
pairwise: bool | None = ...,
6465
bias: bool = ...,
6566
**kwargs,
66-
) -> Series | DataFrame: ...
67+
) -> NDFrameT: ...
6768
def corr(
6869
self,
6970
other: DataFrame | Series | None = ...,
7071
pairwise: bool | None = ...,
7172
**kwargs,
72-
) -> Series | DataFrame: ...
73+
) -> NDFrameT: ...

pandas-stubs/core/window/expanding.pyi

+18-17
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ from pandas.core.window.rolling import (
1414
)
1515

1616
from pandas._typing import (
17-
Axis as Axis,
18-
WindowingRankType as WindowingRankType,
17+
Axis,
18+
NDFrameT,
19+
WindowingRankType,
1920
)
2021

21-
class Expanding(RollingAndExpandingMixin):
22+
class Expanding(RollingAndExpandingMixin[NDFrameT]):
2223
def __init__(
2324
self,
2425
obj: NDFrame,
@@ -46,76 +47,76 @@ class Expanding(RollingAndExpandingMixin):
4647
engine: str | None = ...,
4748
engine_kwargs: dict[str, bool] | None = ...,
4849
**kwargs,
49-
) -> DataFrame | Series: ...
50+
) -> NDFrameT: ...
5051
def max(
5152
self,
5253
*args,
5354
engine: str | None = ...,
5455
engine_kwargs: dict[str, bool] | None = ...,
5556
**kwargs,
56-
) -> DataFrame | Series: ...
57+
) -> NDFrameT: ...
5758
def min(
5859
self,
5960
*args,
6061
engine: str | None = ...,
6162
engine_kwargs: dict[str, bool] | None = ...,
6263
**kwargs,
63-
) -> DataFrame | Series: ...
64+
) -> NDFrameT: ...
6465
def mean(
6566
self,
6667
*args,
6768
engine: str | None = ...,
6869
engine_kwargs: dict[str, bool] | None = ...,
6970
**kwargs,
70-
) -> DataFrame | Series: ...
71+
) -> NDFrameT: ...
7172
def median(
7273
self,
7374
engine: str | None = ...,
7475
engine_kwargs: dict[str, bool] | None = ...,
7576
**kwargs,
76-
) -> DataFrame | Series: ...
77+
) -> NDFrameT: ...
7778
def std(
7879
self,
7980
ddof: int = ...,
8081
*args,
8182
engine: str | None = ...,
8283
engine_kwargs: dict[str, bool] | None = ...,
8384
**kwargs,
84-
) -> DataFrame | Series: ...
85+
) -> NDFrameT: ...
8586
def var(
8687
self,
8788
ddof: int = ...,
8889
*args,
8990
engine: str | None = ...,
9091
engine_kwargs: dict[str, bool] | None = ...,
9192
**kwargs,
92-
) -> DataFrame | Series: ...
93-
def sem(self, ddof: int = ..., *args, **kwargs) -> DataFrame | Series: ...
94-
def skew(self, **kwargs) -> DataFrame | Series: ...
95-
def kurt(self, **kwargs) -> DataFrame | Series: ...
93+
) -> NDFrameT: ...
94+
def sem(self, ddof: int = ..., *args, **kwargs) -> NDFrameT: ...
95+
def skew(self, **kwargs) -> NDFrameT: ...
96+
def kurt(self, **kwargs) -> NDFrameT: ...
9697
def quantile(
9798
self, quantile: float, interpolation: str = ..., **kwargs
98-
) -> DataFrame | Series: ...
99+
) -> NDFrameT: ...
99100
def rank(
100101
self,
101102
method: WindowingRankType = ...,
102103
ascending: bool = ...,
103104
pct: bool = ...,
104105
**kwargs,
105-
) -> DataFrame | Series: ...
106+
) -> NDFrameT: ...
106107
def cov(
107108
self,
108109
other: DataFrame | Series | None = ...,
109110
pairwise: bool | None = ...,
110111
ddof: int = ...,
111112
**kwargs,
112-
) -> DataFrame | Series: ...
113+
) -> NDFrameT: ...
113114
def corr(
114115
self,
115116
other: DataFrame | Series | None = ...,
116117
pairwise: bool | None = ...,
117118
ddof: int = ...,
118119
**kwargs,
119-
) -> DataFrame | Series: ...
120+
) -> NDFrameT: ...
120121

121122
class ExpandingGroupby(BaseWindowGroupby, Expanding): ...

0 commit comments

Comments
 (0)