-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: groupby apply throws error if custom func doesn't return non-None value. #9684
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
Comments
The issue here is that pandas uses
(not entirely sure why that extra So apparently GroupBy.apply doesn't know what to do when it back no non- |
Seems reasonable. I think it's even fine if it throws an informative error, since this is such an odd case. It just took a while to figure out what was going on there. |
Indeed, we all like informative errors. Want to give fixing this a try? |
:) Sure! |
OK @shoyer, added fix. nosetests run ok, as does my own experimentation, but groupby is a pretty complex bit of machinery, so if you wouldn't mind taking a quick look I'd appreciate it. |
closed by #9685 |
This case may be unusual, but I was writing a test to make sure results are sorted within groupby calls, and found that if the
func
in adf.groupby().apply(func)
call doesn't return a value, it causes an error.Minimal code to replicate:
Error:
Traceback (most recent call last):
The problem seems to be due to the function
test_func()
not returning a value, though the error persists even if Ireturn None
intest_func()
.My use, as example of actual situation it might come up:
The text was updated successfully, but these errors were encountered: