-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: ewma() weights incorrect when some values are missing #7603
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
Conversation
can u put the example here before and after |
Here's "before". Note that the final value in the result (the weighted average of 1 and 100) is the same in [2] and [3] and the same in [4] and [5], i.e. the None in the middle does not affect the calculation.
Here's the comparable "after". Note that now the weighted average of 1 and 100 in [3] differs from [2], and that that in [5] differs from [4]. (Note also that in the absence of missing values, the new values are identical to the old, e.g. [2] and [4].)
Finally, the following code shows the weights used by the "old" and "new" methods to calculate the weighted average of 1 and 100 in the presence of a missing value in between them, i.e. [3] and [5] above. First, in [11] and [12] I reproduce the old calculations (which simply ignore the missing value). Then in [13] and [14] I reproduce the new calculations. Note that the only difference is in whether the weight of the two-periods-ago value is (1.-alpha) (old method) or (1.-alpha)**2 (new method).
|
@seth-p this is technically an API change, yes? |
Yes, I guess this should be considered an API change.
|
ok, can you add a release note (API section), with an example showing what is changing? thxs |
Will do.
|
I've updated v0.15.0.txt to reflect this API change. Apologies if it doesn't build properly, as I can't build the docs (using Python 3.4 on Windows). I also fixed the the description of #7766, which appeared to have been truncated. |
no you don't need to do anythjng like that that's the point of the ipython block it runs the code and generates the output reverse all that out pls |
Oh..... I see. OK, will fix. |
OK, I reversed that. I hope I got it more or less right... |
I am thinking that this should be a keyword to control this behavior (mainly to provide backward compat maybe dropna=True (meaning use the new weighting scheme) how hard to allow this? |
Hmm. Probably not too hard, though I would think (a) dropna=True would be the old behavior, and (b) the default should be dropna=False (new behavior). [Though maybe "ignorena" is more descriptive than "dropna", as "dropna" suggests (at least to me) that what's being done is equivalent to ewma(s.dropna()), which isn't quite the case.] Personally I think the old behavior is just plain wrong, but I can live with it if you want it to be the default (and maybe we can change the default in the future...). BTW, is there a forum for discussing such things? I've seen discussions like this in the comments of issues, but I can't imagine that has a wide audience. And my post to https://groups.google.com/forum/#!topic/pydata/woxbB8na3C8 didn't elicit too much feedback... |
I find it easier to discuss here I am ok with having this new behavior the default ignore_na is ok for an argument |
OK, will try to add ignore_na=False to all the ewm*() functions. |
I added ignore_na=False to all ewm*() functions. Let me know how this looks. |
One of the Travis builds failed, but I can't say I understand why: https://travis-ci.org/pydata/pandas/jobs/30710499. |
|
||
Prior to 0.15.0 | ||
|
||
.. code-block:: python |
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.
this is block is not necessary (as the ignore_na
arg shows what you are doing (you can put a comment their),
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.
Deleted this block.
looks good...ping when green |
All is well — The Travis CI build passed |
merged via 24b309f thanks! |
Closes #7543.