ENH: Add pipe method to GroupBy (fixes #10353)
State: closed

closes #10353, extends the "pipe" method to a GroupBy object to allow one to chain it with NDFrame.pipe calls
- Moves the functionality of "pipe" from NDFrame into generics._pipe to avoid code duplication
- Leverages this in GroupBy object
- Adds unit test


Labels:
name: Groupby
name: API Design

Comments:
Sorry I wasn't able to comment on the other thread. Haven't looked at the code here either.

I think this is a good addition, but I've never had the need myself so I can't really speak from experience.

can you rebase

can you rebase. we need a little section in the whatsnew for this. also pls add a small section (can be basically the same) to groupby.rst (and provide a link back to the main pipe usage in basics.rst).

Okay, based on your comments, I did the following:
- Rebased against master
- Added an additional tests that covered argument passing (and presents a less contrived example of the 'pipe' method on a groupby)
- Added a section to doc/source/groupby.rst that describes the pipe method
- Added a similar section to doc/source/whatsnew/v0.17.0.txt

Remaining questions:
- Is the "v0.17.0.tx" the correct release file for the whatsnew?
- Under whatsnew, I added the documentation under "enhancements", but would be happy to put it as a "new feature" if you think that's more accurate.
- The example in the documentation is still very generic.  If you'd prefer, I can give specific implementations of the f, g, and h functions to give more context or motivation to the groupby pipe method.

For the last point, I would simply use those implementations that are in the "tests.test_groupby:test_pipe_args" test that I'm adding here as well.  I could also give some written description.  But I hesitated to do that in this first pass because I wasn't sure that example was too specific for the level of detail in general documentation.  I don't have strong opinions either way, though.

where you put the docs are fine

@ghl3 can you update

@ghl3 can you rebase / update according to comments

Yes, will have an update in the next day or so.  Apologies for the delay.

Best, 
- George

> On Sep 1, 2015, at 7:59 AM, Jeff Reback notifications@github.com wrote:
> 
> @ghl3 https://github.com/ghl3 can you rebase / update according to comments
> 
> —
> Reply to this email directly or view it on GitHub https://github.com/pydata/pandas/pull/10466#issuecomment-136688062.

@ghl3 if you can update this would be gr8

@jreback Updates
- Rebased against master
- Added the "test" example to the documentation
- Cleaned up the "test" example
- The whatsnew now is shorter but provides a link to the docs

couple of comments. pls rebase and squash

Updates:
- Addressed comments in documentation
- Improved the example in the groupby documentation and in the first unit test to (hopefully) be more useful and instructive
- Rebased and squashed all commits

@jorisvandenbossche I've made the requested updates to the documentation style

@jorisvandenbossche what do you think here?

@ghl3 can you rebase pls

@ghl3 can you rebase this

I actually think that this PR is a good example of where less documentation would be better. This is certainly a useful method, but the long motivating example mostly serves to over emphasize these niche uses.

well, I do appreciate good documentation. I think an example is key here. Otherwise people will be wondering why this exists and what its for.

@ghl3 can you rebase / update

@ghl3 pls rebase / update

closing this, but pls reopen if you wish to update