Skip to content

ewm check for mutually exclusive arguments doesn't work when times argument is present #47003

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
trimcrae opened this issue May 11, 2022 · 3 comments · Fixed by #47026
Closed
Labels
Docs Window rolling, ewma, expanding
Milestone

Comments

@trimcrae
Copy link

trimcrae commented May 11, 2022

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.ewm.html ewm is supposed to accept only one of com, span, halflife and alpha and throw a ValueError if multiple are submitted at once. However, when times is input as an argument, this check is bypassed.

@mroeschke
Copy link
Member

Could you provide a minimal code example?

@simonjayhawkins simonjayhawkins added Needs Info Clarification about behavior needed to assess issue Window rolling, ewma, expanding labels May 12, 2022
@trimcrae
Copy link
Author

import pandas as pd
import numpy as np

times = pd.Series([np.datetime64(x) for x in ['2017-01-01', '2017-01-02', '2017-01-03', '2017-01-04']])
values = pd.Series([1, 2, 3, 4])
smoothed_value = values.ewm(alpha = 0.5, halflife = "1 day", times=times).mean()

print(smoothed_value)
print(pd.__version__)
Output:
0    1.000000
1    1.666667
2    2.428571
3    3.266667
dtype: float64
1.4.2

@simonjayhawkins simonjayhawkins added Bug and removed Needs Info Clarification about behavior needed to assess issue labels May 12, 2022
@mroeschke
Copy link
Member

Actually, this is the intended behavior and the documentation just needs updating.

Within the code there's this comment:

            # Halflife is no longer applicable when calculating COM
            # But allow COM to still be calculated if the user passes other decay args

And I think the reason being is allowing the user to not have to reconstruct a new ExponentialMovingWindow if they want to run cov/var/std separately. This behavior is indirectly tested as well in test_online.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Window rolling, ewma, expanding
Projects
None yet
4 participants