-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF/TYP: pandas/core/window/*.py #37091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
516c423
225a2fc
d97f87f
2305216
ec20f00
85b02f3
c56c708
e3b0368
a68ab91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
from textwrap import dedent | ||
from typing import Dict, Optional | ||
from typing import Callable, Dict, Optional, Tuple, Union | ||
|
||
import numpy as np | ||
|
||
from pandas._typing import FrameOrSeries | ||
from pandas.compat.numpy import function as nv | ||
from pandas.util._decorators import Appender, Substitution, doc | ||
|
||
|
@@ -65,7 +68,9 @@ def __init__(self, obj, min_periods=1, center=None, axis=0, **kwargs): | |
def _constructor(self): | ||
return Expanding | ||
|
||
def _get_window(self, other=None, **kwargs): | ||
def _get_window( | ||
self, other: Optional[Union[np.ndarray, FrameOrSeries]] = None, **kwargs | ||
) -> int: | ||
""" | ||
Get the window length over which to perform some operation. | ||
|
||
|
@@ -135,12 +140,12 @@ def count(self, **kwargs): | |
@Appender(_shared_docs["apply"]) | ||
def apply( | ||
self, | ||
func, | ||
func: Callable, | ||
raw: bool = False, | ||
engine: Optional[str] = None, | ||
engine_kwargs: Optional[Dict[str, bool]] = None, | ||
args=None, | ||
kwargs=None, | ||
args: Optional[Tuple] = None, | ||
kwargs: Optional[Dict] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we will eventually want to use disallow_any_generic as we increase strictness checks xref #30539 so for kwargs could probably use can you also add type parameters to Callable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @mroeschke lgtm |
||
): | ||
return super().apply( | ||
func, | ||
|
@@ -183,19 +188,19 @@ def median(self, **kwargs): | |
|
||
@Substitution(name="expanding", versionadded="") | ||
@Appender(_shared_docs["std"]) | ||
def std(self, ddof=1, *args, **kwargs): | ||
def std(self, ddof: int = 1, *args, **kwargs): | ||
nv.validate_expanding_func("std", args, kwargs) | ||
return super().std(ddof=ddof, **kwargs) | ||
|
||
@Substitution(name="expanding", versionadded="") | ||
@Appender(_shared_docs["var"]) | ||
def var(self, ddof=1, *args, **kwargs): | ||
def var(self, ddof: int = 1, *args, **kwargs): | ||
nv.validate_expanding_func("var", args, kwargs) | ||
return super().var(ddof=ddof, **kwargs) | ||
|
||
@Substitution(name="expanding") | ||
@Appender(_shared_docs["sem"]) | ||
def sem(self, ddof=1, *args, **kwargs): | ||
def sem(self, ddof: int = 1, *args, **kwargs): | ||
return super().sem(ddof=ddof, **kwargs) | ||
|
||
@Substitution(name="expanding", func_name="skew") | ||
|
@@ -245,12 +250,23 @@ def quantile(self, quantile, interpolation="linear", **kwargs): | |
@Substitution(name="expanding", func_name="cov") | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs["cov"]) | ||
def cov(self, other=None, pairwise=None, ddof=1, **kwargs): | ||
def cov( | ||
self, | ||
other: Optional[Union[np.ndarray, FrameOrSeries]] = None, | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pairwise: Optional[bool] = None, | ||
ddof: int = 1, | ||
**kwargs, | ||
): | ||
return super().cov(other=other, pairwise=pairwise, ddof=ddof, **kwargs) | ||
|
||
@Substitution(name="expanding") | ||
@Appender(_shared_docs["corr"]) | ||
def corr(self, other=None, pairwise=None, **kwargs): | ||
def corr( | ||
self, | ||
other: Optional[Union[np.ndarray, FrameOrSeries]] = None, | ||
pairwise: Optional[bool] = None, | ||
**kwargs, | ||
): | ||
return super().corr(other=other, pairwise=pairwise, **kwargs) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for clarify should make this
wrap_result_1d
, but can be in the future