-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Inconsistent result with applying function between dataframe/groupby apply and 0.12/0.13/master #6715
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
this is actually quite complicated why it does this. It is trying to detect whether the passed function modifies the input data, which is basically if the returned shape/index is different OR an exception is raised (this is done in cython). In which case it falls back to essentially a loop where the function is tried. An exception here WILL raise though. So the first application succeeds because of the try: except: as you trap the error, the 2nd raises at the appropriate place. I am not sure that I can fix easily. I have something that sort of works, but breaks other things which are 'supposed' to raise, so sorting them will take some effort. |
It appears that the results are identical in master and 0.12. So what is exactly the issue here? |
Yes, when using Eg with apply it does not work, but on a specific group it does:
and on one column it also works:
also with aggregate you get a strange result:
|
IIRC that their were some bugs fixed since 0.13.1 related to this. the last one is a bug I think....ok |
The output I showed was all from current master |
I stumbled upon an inconsistent behaviour in (groupby/dataframe) apply when updating some code from 0.12 to 0.13.
Say you have following custom function:
When you apply this function to a dataframe:
this does work with
P1
, but not withP1_withouttry
. So I constructed my original function with a try/except to be able to apply this on a dataframe with also non-numeric columns.However, when applying this on a groupby, it does not work anymore like this:
So, with
apply
it does not work, withaggregate
it does, but only theP1_withouttry
that didn't work withdf.apply()
.When using
g.agg([P1]
) this does work again on master, but not with 0.13.1 (then it gives the same asg.agg(P1)
), although this did workin 0.12:
It was this last pattern I was using in my code in 0.12 that does not work anymore in 0.13.1 (I had something like
g.agg([P1, P5, P10, P25, np.median, np.mean])
).The text was updated successfully, but these errors were encountered: