-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Bug in df.pct_change() #6389
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
Not a bug, it is pad filling (as the default), which is fill-forward, you can disable by passing
|
@jreback While pad filling is convenient, I think it's quite dangerous as the default. "Errors should never pass silently" and all that Zen. Pandas often drops NaNs for convenience, but dropping NaNs when plotting (for example) isn't nearly as easy to overlook. In fact, I just told someone a moment ago that Backwards compatibility is important, too, but perhaps there's a chance this method could default to For comparison,
seems like it would create the same results as I haven't done a systematic survey of use cases, but in my experience, most time-series analysis would prefer no-fill. When fill-forward is desired, I'd expect that the fill would be done before the pct_change as a more explicit step. |
Hi guys, I think this issue should be re-opened. @selik is absolutely right that "Errors should never pass silently" and unless explicitly done so, this is an error. Not technically, as the default is currently fill_method='pad', but that is not an answer. That is just stating the problem. Upgrading this to fill_method=None is in now way different to deprecating inplace=True, or any other relatively major change that pandas has gone or will go through. |
I agree that this is definitely dangerous as a default value and that this issue should be reopened, if not solved elsewhere. Using pandas |
@jreback Can we reopen this issue with the idea of making a deprecation cycle to switch the default behavior? |
pls make a new issue |
New issue: #28461 . |
df.pct_change incorrectly calculates a value when it shouldn't.
Here is the output:
The text was updated successfully, but these errors were encountered: