8000 Fix type annotations in pandas.core.resample (#26398) · pandas-dev/pandas@0382f20 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0382f20

Browse files
gwromejreback
authored andcommitted
Fix type annotations in pandas.core.resample (#26398)
1 parent e101dd9 commit 0382f20

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

mypy.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ ignore_errors=True
2929
[mypy-pandas.core.panel]
3030
ignore_errors=True
3131

32-
[mypy-pandas.core.resample]
33-
ignore_errors=True
34-
3532
[mypy-pandas.core.reshape.merge]
3633
ignore_errors=True
3734

pandas/core/groupby/grouper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
split-apply-combine paradigm.
44
"""
55

6+
from typing import Tuple
67
import warnings
78

89
import numpy as np
@@ -84,7 +85,8 @@ class Grouper:
8485
8586
>>> df.groupby(Grouper(level='date', freq='60s', axis=1))
8687
"""
87-
_attributes = ('key', 'level', 'freq', 'axis', 'sort')
88+
_attributes = ('key', 'level', 'freq', 'axis',
89+
'sort') # type: Tuple[str, ...]
8890

8991
def __new__(cls, *args, **kwargs):
9092
if kwargs.get('freq') is not None:

pandas/core/resample.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import copy
22
from datetime import timedelta
33
from textwrap import dedent
4+
from typing import Dict, no_type_check
45
import warnings
56

67
import numpy as np
@@ -31,7 +32,7 @@
3132
from pandas.tseries.frequencies import to_offset
3233
from pandas.tseries.offsets import DateOffset, Day, Nano, Tick
3334

34-
_shared_docs_kwargs = dict()
35+
_shared_docs_kwargs = dict() # type: Dict[str, str]
3536

3637

3738
class Resampler(_GroupBy):
@@ -873,25 +874,25 @@ def f(self, _method=method, min_count=0, *args, **kwargs):
873874
for method in ['min', 'max', 'first', 'last', 'mean', 'sem',
874875
'median', 'ohlc']:
875876

876-
def f(self, _method=method, *args, **kwargs):
877+
def g(self, _method=method, *args, **kwargs):
877878
nv.validate_resampler_func(_method, args, kwargs)
878879
return self._downsample(_method)
879-
f.__doc__ = getattr(GroupBy, method).__doc__
880-
setattr(Resampler, method, f)
880+
g.__doc__ = getattr(GroupBy, method).__doc__
881+
setattr(Resampler, method, g)
881882

882883
# groupby & aggregate methods
883884
for method in ['count']:
884-
def f(self, _method=method):
885+
def h(self, _method=method):
885886
return self._downsample(_method)
886-
f.__doc__ = getattr(GroupBy, method).__doc__
887-
setattr(Resampler, method, f)
887+
h.__doc__ = getattr(GroupBy, method).__doc__
888+
setattr(Resampler, method, h)
888889

889890
# series only methods
890891
for method in ['nunique']:
891-
def f(self, _method=method):
892+
def h(self, _method=method):
892893
return self._downsample(_method)
893-
f.__doc__ = getattr(SeriesGroupBy, method).__doc__
894-
setattr(Resampler, method, f)
894+
h.__doc__ = getattr(SeriesGroupBy, method).__doc__
895+
setattr(Resampler, method, h)
895896

896897

897898
def _maybe_process_deprecations(r, how=None, fill_method=None, limit=None):
@@ -964,6 +965,7 @@ def __init__(self, obj, *args, **kwargs):
964965
self._groupby.grouper.mutated = True
965966
self.groupby = copy.copy(parent.groupby)
966967

968+
@no_type_check
967969
def _apply(self, f, grouper=None, *args, **kwargs):
968970
"""
969971
Dispatch to _upsample; we are stripping all of the _upsample kwargs and

0 commit comments

Comments
 (0)
0