Skip to content

BUG: invalid rolling window on empty input #21291

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

Merged
merged 14 commits into from
Jun 8, 2018
4 changes: 2 additions & 2 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ def validate(self):
if isinstance(window, (list, tuple, np.ndarray)):
pass
elif is_integer(window):
if window < 0:
raise ValueError("window must be non-negative")
if window <= 0:
raise ValueError("please enter a positive window")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe : window must be > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback is this a suggestion for ValueError message?

try:
import scipy.signal as sig
except ImportError:
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ def test_constructor(self, which):
c(window=2, min_periods=1, center=False)

# GH 13383
c(0)
with pytest.raises(ValueError):
c(0)
c(-1)

# not valid
Expand All @@ -409,7 +409,6 @@ def test_constructor_with_win_type(self, which):
# GH 13383
o = getattr(self, which)
c = o.rolling
c(0, win_type='boxcar')
with pytest.raises(ValueError):
c(-1, win_type='boxcar')

Expand Down