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

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Suppress type checking for _GroupByMixin._apply
  • Loading branch information
gwrome committed May 14, 2019
commit 1abd09967397af331b51169e46a57f401d7b10cf
2 changes: 1 addition & 1 deletion pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
split-apply-combine paradigm.
"""

from Typing import Tuple
from typing import Tuple
import warnings

import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/resample.py
8000
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
from datetime import timedelta
from textwrap import dedent
from typing import Dict
from typing import Dict, no_type_check
import warnings

import numpy as np
Expand Down Expand Up @@ -965,6 +965,7 @@ def __init__(self, obj, *args, **kwargs):
self._groupby.grouper.mutated = True
self.groupby = copy.copy(parent.groupby)

@no_type_check
Copy link
Contributor Author
@gwrome gwrome May 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has a set of mismatched signatures that's much more involved to bring into alignment that the ones we did in other PRs.

_upsample

DatetimeIndexResampler and Resampler both define an _upsample method. The two signatures are only marginally different and could be harmonized easily. But _GroupByMixin defines an _apply method that is significantly different and then assigns that method to the class's _upsample variable (as well as _downsample and _groupby_and_aggregate).

_downsample

_downsample has similar relationships between PeriodIndexResampler, DatetimeIndexResampler, and _GroupByMixin`.

_groupby_and_aggregate

_groupby_and_aggregate has similar relationships between Resampler and _GroupByMixin.

Some parts of the _apply signature appear to be unused in this file. I'm investigating how much mucking around I can do with them. It might be possible to bring them all in alignment.

7749
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gwrome there is lots of magic to make grouby/resample/rolling play nicely. But can of course do this another time.

def _apply(self, f, grouper=None, *args, **kwargs):
"""
Dispatch to _upsample; we are stripping all of the _upsample kwargs and
Expand Down
0