-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
CLN: Breakup agg #37452
Conversation
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.
Apart from mypy error, LGTM.
if obj.ndim == 1: | ||
obj = cast("Series", obj) |
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.
Is it the same as this?
if isinstance(obj, Series):
...
No need for casting.
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.
See #36677 for a discussion on this section; note that Series
is no longer imported in this module.
# combine results | ||
if all(is_ndframe): |
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.
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.
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.
yeah this would be nice, this pass or next ok
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.
Agreed, and am working in that direction.
pandas/core/aggregation.py
Outdated
def aggregate_multiple_funcs(obj, arg, _axis): | ||
def agg_list_like(obj, arg, _axis): |
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.
Clear function rename!
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.
can you type the newer functions and add doc-strings , ping on green.
# combine results | ||
if all(is_ndframe): |
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.
yeah this would be nice, this pass or next ok
Docstrings aren't quite right here; obj can be other types. Hold off on merging. |
Tests pass when adding the following line to aggregation.aggregate:
This is a bit ghastly, going to just leave the description as generic unless this specificity is desired. |
@jreback green-ish |
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.
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, |
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.
if you can type this as some point (obj), FrameOrSeries i think.
|
||
def agg_dict_like( | ||
obj, | ||
arg: Dict[Label, Union[AggFuncTypeBase, List[AggFuncTypeBase]]], |
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.
maybe alias this
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Extracted dictionary parts to
agg_dict_like
, and changed fromisinstance(arg, dict)
tois_dict_like(arg)
. Also renamedaggregate_multiple_funcs
toagg_list_like
.