pydata/pandas — pull request #3680 by danielballan (2013-05-22 02:43:16+00:00)
Title: EHN: Add filter method to SeriesGroupBy GH919

I have been using Wes' workaround (see #919) for filtering groups. Finally, for brevity's sake, I wrote a real filter method. In the one simple case I checked, it performs faster than the workaround.

In [7]: %timeit grouped.filter(lambda x: x.mean() > 10) # my method
1000 loops, best of 3: 346 us per loop

In [8]: %timeit grouped.obj[grouped.transform(lambda x: x.mean() > 10)] # workaround
1000 loops, best of 3: 462 us per loop

This PR only handles Series, and I included one simple test. If I am on the right track, I'll write one for DataFrames also. If this is a job for Cython, I'm out of my depth, but I think numpy is sufficient. Does this look OK?