Skip to content
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

docs(python): correct defaults documented in emw_mean #14653

Closed

Conversation

MarcoGorelli
Copy link
Collaborator

addresses part of #13017

  • note the default for adjust in the docstring
  • correct the documented default for ignore_nulls

Suppose you have

In [26]: s = pl.Series([5, None, None, 9])

In [27]: alpha = .3

In [28]: w_0 = 1

Then currently, when calculating the result for 9, the weight for 5 is (1-alpha):

In [29]: s.ewm_mean(alpha=alpha)
Out[29]:
shape: (4,)
Series: '' [f64]
[
        5.0
        5.0
        5.0
        7.352941
]

In [30]: w_1 = (1-alpha); print((9*w_0 + 5*w_1)/(w_0+w_1))
7.352941176470589

With ignore_nulls=False, it would be (1-alpha)**3:

In [31]: s.ewm_mean(alpha=alpha, ignore_nulls=False)
Out[31]:
shape: (4,)
Series: '' [f64]
[
        5.0
        5.0
        5.0
        7.978407
]

In [32]: w_1 = (1-alpha)**3; print((9*w_0 + 5*w_1)/(w_0+w_1))
7.978406552494415

Just confirming that the default really is True currently (personally I'd find False more intuitive, but that's for a separate discussion)

@github-actions github-actions bot added documentation Improvements or additions to documentation python Related to Python Polars labels Feb 23, 2024
@MarcoGorelli
Copy link
Collaborator Author

as per discussion today - this will be deprecated and behaviour brought in-line with the current docstring in 1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant