-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix rolling functions with variable windows on decreasing index #32386
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 all commits
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 |
---|---|---|
|
@@ -709,20 +709,25 @@ def test_rolling_cov_offset(self): | |
tm.assert_series_equal(result, expected2) | ||
|
||
def test_rolling_on_decreasing_index(self): | ||
# GH-19248 | ||
# GH-19248, GH-32385 | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
index = [ | ||
Timestamp("20190101 09:00:00"), | ||
Timestamp("20190101 09:00:02"), | ||
Timestamp("20190101 09:00:03"), | ||
Timestamp("20190101 09:00:05"), | ||
Timestamp("20190101 09:00:06"), | ||
Timestamp("20190101 09:00:30"), | ||
Timestamp("20190101 09:00:27"), | ||
Timestamp("20190101 09:00:20"), | ||
Timestamp("20190101 09:00:18"), | ||
Timestamp("20190101 09:00:10"), | ||
] | ||
|
||
df = DataFrame({"column": [3, 4, 4, 2, 1]}, index=reversed(index)) | ||
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. Wouldn't this have been working previously with a decreasing index? 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. Not fully sure what the question is, but: on 0.25 we raised an error for decreasing index. For 1.0, rolling with a decreasing index was enabled, but gave wrong output (see eg #32385 for what the output of this should actually be) 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. v1.0 would return [3,3,3,2,1] for this case. The rolling window covered the whole series. |
||
result = df.rolling("2s").min() | ||
expected = DataFrame( | ||
{"column": [3.0, 3.0, 3.0, 2.0, 1.0]}, index=reversed(index) | ||
) | ||
df = DataFrame({"column": [3, 4, 4, 5, 6]}, index=index) | ||
result = df.rolling("5s").min() | ||
expected = DataFrame({"column": [3.0, 3.0, 4.0, 4.0, 6.0]}, index=index) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_rolling_on_empty(self): | ||
# GH-32385 | ||
df = DataFrame({"column": []}, index=[]) | ||
result = df.rolling("5s").min() | ||
expected = DataFrame({"column": []}, index=[]) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_rolling_on_multi_index_level(self): | ||
|
Uh oh!
There was an error while loading. Please reload this page.