-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
15819 rolling window on empty df #16431
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 7 commits
9cbaef6
d31b983
5fb1170
670a33a
e913664
985522f
6007654
4a81a5e
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 |
---|---|---|
|
@@ -441,6 +441,19 @@ def test_closed(self): | |
with pytest.raises(ValueError): | ||
df.rolling(window=3, closed='neither') | ||
|
||
@pytest.mark.parametrize('roller', ['1s', 1]) | ||
def tests_empty_df_rolling(self, roller): | ||
# Verifies that datetime and integer rolling windows can be applied to empty DataFrames | ||
# GH 15819 | ||
expected = DataFrame() | ||
result = DataFrame().rolling(roller).sum() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
# Verifies that datetime and integer rolling windows can be applied to empty DataFrames with datetime index | ||
expected = DataFrame(index=pd.DatetimeIndex([])) | ||
result = DataFrame(index=pd.DatetimeIndex([])).rolling(roller).sum() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
class TestExpanding(Base): | ||
|
||
|
@@ -483,6 +496,35 @@ def test_numpy_compat(self): | |
tm.assert_raises_regex(UnsupportedFunctionCall, msg, | ||
getattr(e, func), dtype=np.float64) | ||
|
||
# TODO: GH 16425: Add '1s' datetime expander when GH 16425 is resolved | ||
@pytest.mark.parametrize('expander', [1]) | ||
def tests_empty_df_expanding(self, expander): | ||
# Verifies that datetime and integer expanding windows can be applied to empty DataFrames | ||
# GH 15819 | ||
expected = DataFrame() | ||
result = DataFrame().expanding(expander).sum() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
# Verifies that datetime and integer expanding windows can be applied to empty DataFrames with datetime index | ||
expected = DataFrame(index=pd.DatetimeIndex([])) | ||
result = DataFrame(index=pd.DatetimeIndex([])).expanding(expander).sum() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
# TODO: GH 16425: Remove this test and add '1s' to roller parameter of test_empty_df_expanding() parameter | ||
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. these lines are too long for the linter |
||
# when GH 16425 is resolved | ||
@pytest.mark.xfail(reason="Open issue GH 16425") | ||
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. make a referece to what this issue is fixing as well (like I showed above), this is a printed warning when running the tests e.g.
|
||
def tests_empty_df_expanding_datetime(self): | ||
# Verifies that datetime and integer expanding windows can be applied to empty DataFrames | ||
# GH 15819 | ||
expected = DataFrame() | ||
result = DataFrame().expanding('1s').sum() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
# Verifies that datetime and integer expanding windows can be applied to empty DataFrames with datetime index | ||
expected = DataFrame(index=pd.DatetimeIndex([])) | ||
result = DataFrame(index=pd.DatetimeIndex([])).expanding('1s').sum() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
class TestEWM(Base): | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you can add in a parameter that xfails itself, IOW