-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
TST: add test case for user-defined function taking correct path in groupby transform #29631
Conversation
But the |
@jbrockmendel these are all failing for the web / docs stuff? |
Yes, but the sole call to _choose_path is itself wrapped in a It's entirely possible that I'm missing something. In recent threads you've shown a talent for finding corner cases that are currently missing from the tests. Any ideas for what cases will raise here that we should worry about? |
Not sure yet whats going on there. Could well be an example we can/should add to the tests! |
Probably yes, it's in any case a transform with a UDF that is failing |
@jorisvandenbossche i found the case from cookbook.rst that is failing in this PR, but it isn't clear to me that it is behaving correctly on master either. I'd like to get a second opinion.
I expected |
It's what the function seems to be doing:
So maybe the function is doing something unexpected, but it seems the I find |
@jorisvandenbossche for the immediate purpose of this PR, I'm implementing a test case where fast_path raises, but I don't want to use a not-clearly-correct case. Can you suggest one? (this might be obvious, but i need caffeine) The follow-on issues are a) making sure the example in the docs is correct and b) making sure |
As far as I understand, the example in the docs is correct |
Updated. Now the behavior is unchanged, just added a test that requires the current behavior. Thanks for helping me understanding it @jorisvandenbossche |
|
||
def replace(g): | ||
mask = g < 0 | ||
return g.where(mask, g[~mask].mean()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be good to use a simpler function to test here (otherwise somebody later looking at the test will have the same "what the heck is this UDF doing" thought as we had now). It just needs to be a function that accepts a Series / returns a Series of the same shape, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good!
thanks @jbrockmendel |
I kept this one in place because I thought fast_path could be user-defined (see comment on L1425), but it turns out we define it in _define_paths a few lines above. So this try/except is unnecessary.