pandas: CLN remove unreachable code in pandas/core/groupby/generic.py::DataFrameGroupBy::_wrap_applied_output

NOTE: I’d originally opened a PR to address this, but am now busy with other obligations + other PRs to respond to. So I’m opening it up as a good first issue for now, and will return to work on it if nobody takes it.


In pandas/core/groupby/generic.py::DataFrameGroupBy::_wrap_applied_output, it seems this branch is never reached:

        else:
            # Handle cases like BinGrouper
            return self._concat_objects(keys, values, not_indexed_same=not_indexed_same)

Two things need to be done here:

  1. refactor _wrap_applied_output by making a helper function out of some of its internals (it’s currently very long, and changes are hard to review)
  2. Remove this unused else branch

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (13 by maintainers)

Most upvoted comments

Hi @fokoid , thanks for bringing my attention back to this - it looks like @rhshadrach has already done some excellent refactoring here, this function is now significantly simpler than it was when I opened this, so IMO we’re OK to close

Nonetheless, there are many open issues to work on, any help there would be welcome!

I think the first steps are to look at the _transform_general function and see how it could be broken down in more manageable/reusable functions. Might be quite a challenging good first issue - but feel free to give it a shot and let us know if you have any questions