Should ewm_mean preserve null values? #15258
Labels
bug
Something isn't working
needs triage
Awaiting prioritization by a maintainer
python
Related to Python Polars
Checks
Reproducible example
Log output
No response
Issue description
The second element is null, but the result forward fills the previous one. I think there's no need to, though?
Without nulls, the formula would be:
y_0
=x_0
y_1
=weighted_average([x_1, y_0], weights=[alpha, 1-alpha])
y_2
=weighted_average([x_2, y_1], weights=[alpha, 1-alpha])
If
x_1
is null, then the null values are skipped, and the result is scaled appropriately:y_0
=x_0
y_1
= ???y_2
:weighted_average([x_2, y_0], weights=[alpha, (1-alpha)**2])
ifignore_nulls=False
weighted_average([x_2, y_0], weights=[alpha, 1-alpha])
ifignore_nulls=True
y_1
isn't used anywhere in any calculation. It doesn't need to be forward-filled fromy_0
, right?Expected behavior
I think null values should be preserved. So, the output should be (imo):
I don't think this needs to be configurable either, it's easy to just add
.forward_fill()
to an expression chain if you want the nulls filledAs for how to go about changing it, I don't know - maybe it's fair game as a clearly documented and called-out breaking 1.0 change?
Installed versions
The text was updated successfully, but these errors were encountered: