Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should GroupBy.transform exclude nuisance columns? #1364

wesm opened this issue May 31, 2012 · 0 comments


Copy link

commented May 31, 2012

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
   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

@ghost ghost assigned wesm May 31, 2012

@wesm wesm closed this in f62f571 Jun 2, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.