Skip to content

Commit 3d67900

Browse files
author
Kevin Sheppard
committed
ENH: Add generic
1 parent eeeb61b commit 3d67900

File tree

6 files changed

+76
-72
lines changed

6 files changed

+76
-72
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

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from typing import Any
1+
from typing import (
2+
Any,
3+
Generic,
4+
)
25

36
import numpy as np
47
from pandas import (
@@ -10,10 +13,11 @@ from pandas.core.window.rolling import BaseWindow
1013

1114
from pandas._typing import (
1215
Axis,
16+
NDFrameT,
1317
TimedeltaConvertibleTypes,
1418
)
1519

16-
class ExponentialMovingWindow(BaseWindow):
20+
class ExponentialMovingWindow(BaseWindow[NDFrameT]):
1721
com: Any = ... # Incomplete
1822
span: Any = ... # Incomplete
1923
halflife: Any = ... # Incomplete
@@ -23,7 +27,7 @@ class ExponentialMovingWindow(BaseWindow):
2327
times: Any = ... # Incomplete
2428
def __init__(
2529
self,
26-
obj: NDFrame,
30+
obj: NDFrameT,
2731
com: float | None = ...,
2832
span: float | None = ...,
2933
halflife: float | TimedeltaConvertibleTypes | None = ...,
@@ -46,27 +50,27 @@ class ExponentialMovingWindow(BaseWindow):
4650
engine: Any | None = ...,
4751
engine_kwargs: Any | None = ...,
4852
**kwargs,
49-
) -> Series | DataFrame: ...
53+
) -> NDFrameT: ...
5054
def sum(
5155
self,
5256
*args,
5357
engine: Any | None = ...,
5458
engine_kwargs: Any | None = ...,
5559
**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: ...
60+
) -> NDFrameT: ...
61+
def std(self, bias: bool = ..., *args, **kwargs) -> NDFrameT: ...
62+
def vol(self, bias: bool = ..., *args, **kwargs) -> NDFrameT: ...
63+
def var(self, bias: bool = ..., *args, **kwargs) -> NDFrameT: ...
6064
def cov(
6165
self,
6266
other: DataFrame | Series | None = ...,
6367
pairwise: bool | None = ...,
6468
bias: bool = ...,
6569
**kwargs,
66-
) -> Series | DataFrame: ...
70+
) -> NDFrameT: ...
6771
def corr(
6872
self,
6973
other: DataFrame | Series | None = ...,
7074
pairwise: bool | None = ...,
7175
**kwargs,
72-
) -> Series | DataFrame: ...
76+
) -> 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)