Skip to content

CLN: Breakup agg #37452

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 4 commits into from
Oct 30, 2020
Merged

CLN: Breakup agg #37452

merged 4 commits into from
Oct 30, 2020

Conversation

rhshadrach
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Extracted dictionary parts to agg_dict_like, and changed from isinstance(arg, dict) to is_dict_like(arg). Also renamed aggregate_multiple_funcs to agg_list_like.

@rhshadrach rhshadrach added Clean Apply Apply, Aggregate, Transform, Map labels Oct 27, 2020
Copy link
Member

@ivanovmg ivanovmg left a comment

Choose a reason for hiding this comment

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

Apart from mypy error, LGTM.

Comment on lines +731 to +732
if obj.ndim == 1:
obj = cast("Series", obj)
Copy link
Member

Choose a reason for hiding this comment

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

Is it the same as this?

if isinstance(obj, Series):
   ...

No need for casting.

Copy link
Member Author

Choose a reason for hiding this comment

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

See #36677 for a discussion on this section; note that Series is no longer imported in this module.

Comment on lines +712 to +713
# combine results
if all(is_ndframe):
Copy link
Member

Choose a reason for hiding this comment

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

In my opinion, would be even better to have this if/elif/else statement in a separate function.
I would not suggest the best name, but I can infer from the comment that something containing combine could be the way to go.
Although, not a big deal.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this would be nice, this pass or next ok

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, and am working in that direction.

Comment on lines 670 to 573
def aggregate_multiple_funcs(obj, arg, _axis):
def agg_list_like(obj, arg, _axis):
Copy link
Member

Choose a reason for hiding this comment

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

Clear function rename!

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

can you type the newer functions and add doc-strings , ping on green.

Comment on lines +712 to +713
# combine results
if all(is_ndframe):
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this would be nice, this pass or next ok

@jreback jreback added this to the 1.2 milestone Oct 29, 2020
@rhshadrach rhshadrach added the Typing type annotations, mypy/pyright type checking label Oct 29, 2020
@rhshadrach
Copy link
Member Author

Docstrings aren't quite right here; obj can be other types. Hold off on merging.

@rhshadrach
Copy link
Member Author

Tests pass when adding the following line to aggregation.aggregate:

assert isinstance(obj, (Series, DataFrame, SeriesGroupBy, DataFrameGroupBy, BaseWindow, Resampler))

This is a bit ghastly, going to just leave the description as generic unless this specificity is desired.

@rhshadrach
Copy link
Member Author

@jreback green-ish

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

thanks @rhshadrach some followon suggestion as I know you are tesing this whole module apart

@@ -528,133 +528,44 @@ def transform_str_or_callable(
return func(obj, *args, **kwargs)


def aggregate(obj, arg: AggFuncType, *args, **kwargs):
def aggregate(
obj,
Copy link
Contributor

Choose a reason for hiding this comment

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

if you can type this as some point (obj), FrameOrSeries i think.


def agg_dict_like(
obj,
arg: Dict[Label, Union[AggFuncTypeBase, List[AggFuncTypeBase]]],
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe alias this

@jreback jreback merged commit 6611ea7 into pandas-dev:master Oct 30, 2020
@rhshadrach rhshadrach deleted the agg_breakup branch October 31, 2020 02:28
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
ukarroum pushed a commit to ukarroum/pandas that referenced this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Clean Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants