-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Description
In [46]: print df; df.groupby('key1').transform(lambda x: x.mean())
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/home/wesm/Dropbox/book/svn/book_scripts/notebooks/<ipython-input-46-656cf72f4323> in <module>()
1 print df
----> 2 df.groupby('key1').transform(lambda x: x.mean())
/home/wesm/code/pandas/pandas/core/groupby.pyc in transform(self, func, *args, **kwargs)
1639 group.T.values[:] = res
1640 else:
-> 1641 group.values[:] = res
1642
1643 applied.append(group)
ValueError: operands could not be broadcast together with shapes (3,4) (2)
data1 data2 key1 key2
0 0.984916 0.904550 a one
1 -1.879638 0.585887 a two
2 0.457879 -0.721776 b one
3 1.585887 0.050336 b two
4 -0.701547 0.525808 a one