pydata/pandas — pull request #8128 by behzadnouri (2014-08-28 02:47:09+00:00)
Title: ENH: speed up multi-key groupby

Improves multi-key `groupby` speed; On master:

In [3]: pd.__version__
Out[3]: '0.14.1-276-g995f91c'

In [4]: np.random.seed(2718281)

In [5]: n = 20000

In [6]: df = pd.DataFrame(np.random.randint(1, n, (n, 3)),
...: columns=['jim', 'joe', 'jolie'])

In [7]: %timeit df.groupby(['jim', 'joe'])['jolie'].transform('max')
1 loops, best of 3: 1.05 s per loop
with this patch:

In [10]: %timeit df.groupby(['jim', 'joe'])['jolie'].transform('max')
10 loops, best of 3: 120 ms per loop