-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: rolling mean and sum not numerical stable for all nan window #41106
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
Changes from 3 commits
7128769
6089767
193bc36
4599fed
958fe59
3933867
8711cce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1357,3 +1357,49 @@ def test_rolling_std_small_values(): | |
result = s.rolling(2).std() | ||
expected = Series([np.nan, 7.071068e-9, 7.071068e-9]) | ||
tm.assert_series_equal(result, expected, atol=1.0e-15, rtol=1.0e-15) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"start, exp_values", | ||
[ | ||
(1, [0.03, 0.0155, 0.0155, 0.011, 0.01025]), | ||
(2, [0.001, 0.001, 0.0015, 0.00366666]), | ||
], | ||
) | ||
def test_rolling_mean_all_nan_window_floating_artifacts(start, exp_values): | ||
# GH#41053 | ||
df = DataFrame( | ||
[ | ||
0.03, | ||
0.03, | ||
0.001, | ||
np.NaN, | ||
0.002, | ||
0.008, | ||
np.NaN, | ||
np.NaN, | ||
np.NaN, | ||
np.NaN, | ||
np.NaN, | ||
np.NaN, | ||
0.005, | ||
0.2, | ||
] | ||
) | ||
|
||
values = exp_values + [ | ||
0.00366666, | ||
0.005, | ||
0.005, | ||
0.008, | ||
np.NaN, | ||
np.NaN, | ||
0.005, | ||
0.102500, | ||
] | ||
expected = DataFrame( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mind parameterizing over There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could yes, but you make a pretty long parametrization, because most of exepected differs too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parametrized, got a bit better :) |
||
values, | ||
index=list(range(start, len(values) + start)), | ||
) | ||
result = df.iloc[start:].rolling(5, min_periods=0).mean() | ||
tm.assert_frame_equal(result, expected) |
Uh oh!
There was an error while loading. Please reload this page.