-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Bug in rolling_* functions when combining center and min_periods arguments #7925
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
cc @seth-p want to have a look the |
I have to admit I've hardly ever even looked at the CC'ing @changhiskhan, who seems to have worked on |
OK, I see what's going on. The way the code works, when you call So in the example provided, regardless of the value of Now, clearly what you're expecting is that in the I suppose that in the |
For reference, the only difference between
I must admit that I don't quite follow all the details in this slicing business. |
I debugged this a year or so ago that's why I say it's fragile |
Well, I think I could modify the code so that, in the case |
I think what we really need is a better doc on what it's supposed to do can u take a look at past PRs and see if u can figure out? it's the edge conditions that are tricky |
For starters, here's a stupid question: In |
ahh in theory the roll functions can deal with that as well (I think wesm wanted to support that originally) |
OK, I see. I think it should be straightforward. |
OK, I think seth-p@6e2eefc addresses the problem. Note that I still need to update the tests (they expect NaNs where now there are values). But let me know how this looks. |
I've submitted a PR for this. If it looks ok for 0.15.0, I will update the v0.15.0 release notes. |
Note that this also affects In [11]: expanding_mean(s, center=True) In [12]: expanding_mean(s, min_periods=0, center=True)
|
Come to think of it, the Perhaps best simply to remove the |
Actually, looks like it's totally straightforward to remove |
I removed |
Hello,
I have found some incorrect behavior in the pd.rolling_* functions regarding the combination of 'center' and 'min_periods' arguments. I believe this is an issue for all rolling_* functions. Here is an example using rolling_mean:
When using only the 'center' argument, the behavior works as expected:
When using the 'min_periods' argument, the behavior also works as expected:
When combining both the 'center' and 'min_periods' arguments, however, the result is incorrect. The last entry should be 8.5 I believe.
The text was updated successfully, but these errors were encountered: