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: 4 additions & 0 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def is_freq_type(self):
return self.win_type == 'freq'

def validate(self):
if self.window == 0:
Copy link
Member

Choose a reason for hiding this comment

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

As @mroeschke pointed out can't you combine this with the check below? Don't think we need this

raise ValueError("Please Enter a window other than 0")
if self.center is not None and not is_bool(self.center):
raise ValueError("center must be a boolean")
if self.min_periods is not None and not \
Expand Down Expand Up @@ -602,6 +604,8 @@ def validate(self):
if isinstance(window, (list, tuple, np.ndarray)):
pass
elif is_integer(window):
if window == 0:
Copy link
Member

Choose a reason for hiding this comment

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

Instead, you can combine this check with the one below (i.e window <= 0) and then raise an appropriate error message

raise ValueError("window must not be zero")
if window < 0:
raise ValueError("window must be non-negative")
try:
Expand Down