8000 Fix type annotations in pandas.core.resample by gwrome · Pull Request #26398 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Fix type annotations in pandas.core.resample #26398

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

Merged
merged 2 commits into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

8000
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Begin correctin type annotations in core.resample
  • Loading branch information
gwrome committed May 14, 2019
commit ac8a7140ef0a4123365ef46c7b84df63cd14ba5c
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ ignore_errors=True
[mypy-pandas.core.panel]
ignore_errors=True

[mypy-pandas.core.resample]
ignore_errors=True

[mypy-pandas.core.reshape.merge]
ignore_errors=True

Expand Down
4 changes: 3 additions & 1 deletion pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
split-apply-combine paradigm.
"""

from Typing import Tuple
import warnings

import numpy as np
Expand Down Expand Up @@ -84,7 +85,8 @@ class Grouper:

>>> df.groupby(Grouper(level='date', freq='60s', axis=1))
"""
_attributes = ('key', 'level', 'freq', 'axis', 'sort')
_attributes = ('key', 'level', 'freq', 'axis',
'sort') # type: Tuple[str, ...]

def __new__(cls, *args, **kwargs):
if kwargs.get('freq') is not None:
Expand Down
21 changes: 11 additions & 10 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
from datetime import timedelta
from textwrap import dedent
from typing import Dict
import warnings

import numpy as np
Expand Down Expand Up @@ -31,7 +32,7 @@
from pandas.tseries.frequencies import to_offset
from pandas.tseries.offsets import DateOffset, Day, Nano, Tick

_shared_docs_kwargs = dict()
_shared_docs_kwargs = dict() # type: Dict[str, str]


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

def f(self, _method=method, *args, **kwargs):
def g(self, _method=method, *args, **kwargs):
nv.validate_resampler_func(_method, args, kwargs)
return self._downsample(_method)
f.__doc__ = getattr(GroupBy, method).__doc__
setattr(Resampler, method, f)
g.__doc__ = getattr(GroupBy, method).__doc__
setattr(Resampler, method, g)

# groupby & aggregate methods
for method in ['count']:
def f(self, _method=method):
def h(self, _method=method):
return self._downsample(_method)
f.__doc__ = getattr(GroupBy, method).__doc__
setattr(Resampler, method, f)
h.__doc__ = getattr(GroupBy, method).__doc__
setattr(Resampler, method, h)

# series only methods
for method in ['nunique']:
def f(self, _method=method):
def h(self, _method=method):
return self._downsample(_method)
f.__doc__ = getattr(SeriesGroupBy, method).__doc__
setattr(Resampler, method, f)
h.__doc__ = getattr(SeriesGroupBy, method).__doc__
setattr(Resampler, method, h)


def _maybe_process_deprecations(r, how=None, fill_method=None, limit=None):
Expand Down
0