Skip to content

BUG: ewma with time should not update value when timedelta between two steps is 0 #40099

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

Closed
1 task
jasonzhang2s opened this issue Feb 27, 2021 · 2 comments
Closed
1 task
Labels
Bug Closing Candidate May be closeable, needs more eyeballs Window rolling, ewma, expanding

Comments

@jasonzhang2s
Copy link

jasonzhang2s commented Feb 27, 2021

  • [yes ] I have checked that this issue has not already been reported.

  • [ yes] I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

idx=pd.date_range('20000101','20201231')

idx2=[idx[0]]*5 + [idx[1]]*5

df=pd.DataFrame(data=range(10),index=idx2)

df.ewm(halflife=pd.Timedelta('1D'), times=df.index).mean()
# Your code here
  0
0.000000
0.500000
1.000000
1.500000
2.000000
2.857143
3.555556
4.181818
4.769231
5.333333

Problem description

Why is the value being updated when time hasn't elapsed yet?

Expected Output

Output of pd.show_versions()

[paste the output of pd.show_versions() here leaving a blank line after the details tag]

@jasonzhang2s jasonzhang2s added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 27, 2021
@mroeschke
Copy link
Member

From the formula we're using (https://pandas.pydata.org/docs/user_guide/window.html#exponentially-weighted-window in the times section), when the timedelta is 0 the weights equal 1 and therefore the op acts like an expanding mean.

@mroeschke mroeschke added Closing Candidate May be closeable, needs more eyeballs Window rolling, ewma, expanding and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 1, 2021
@mroeschke
Copy link
Member

Going to close as I believe this is the expected behavior, but happy to reopen if I am missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Closing Candidate May be closeable, needs more eyeballs Window rolling, ewma, expanding
Projects
None yet
Development

No branches or pull requests

2 participants