Skip to content

CLN: trim unreachable groupby paths #41361

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 1 commit into from
May 7, 2021

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry

@jreback jreback added this to the 1.3 milestone May 6, 2021
# "Optional[List[str]]", variable has type "Index")
ret.columns = columns # type: ignore[assignment]
return ret

Copy link
Contributor

Choose a reason for hiding this comment

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

you could outdent (and remove the else) here to make it more obvious

Copy link
Member Author

Choose a reason for hiding this comment

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

considered that, but this mirrors the layout of the DataFrameGroupBy method and im holding out hope of sharing more of that

@jreback jreback merged commit 170b439 into pandas-dev:master May 7, 2021
@jbrockmendel jbrockmendel deleted the cln-gb-unreached branch May 7, 2021 15:59
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
@@ -1000,6 +998,11 @@ def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs)
result = op.agg()
if not is_dict_like(func) and result is not None:
return result
elif relabeling and result is not None:
# this should be the only (non-raising) case with relabeling
Copy link
Member Author

Choose a reason for hiding this comment

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

@rhshadrach i wrote this comment a few years ago and now need help figuring it out. in particular, can re rule out relabeling and result is None? Or is that a shortcoming of the test suite?

Copy link
Member

Choose a reason for hiding this comment

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

Yes - it is not possible that relabeling is True and result is None. If relabeling is True, the func returned from reconstruct_func must be the result from normalize_keyword_aggregation which is a dictionary. In the case of a dict-like, the result is always computed in Apply.agg via Apply.agg_dict_like.

Copy link
Member Author

@jbrockmendel jbrockmendel Feb 8, 2023

Choose a reason for hiding this comment

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

so this condition can be replaced with elif relabeling:?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. Also, as an aside, I think it was a misstep to try to reuse the code in core.apply for groupby.agg. I don't have any concrete ideas for cleaning this up yet, but it's on my radar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants