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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Groupby/Resample/Rolling
- Bug in :func:`DataFrame.agg` where applying multiple aggregation functions to a :class:`DataFrame` with duplicated column names would cause a stack overflow (:issue:`21063`)
- Bug in :func:`pandas.core.groupby.GroupBy.ffill` and :func:`pandas.core.groupby.GroupBy.bfill` where the fill within a grouping would not always be applied as intended due to the implementations' use of a non-stable sort (:issue:`21207`)
- Bug in :func:`pandas.core.groupby.GroupBy.rank` where results did not scale to 100% when specifying ``method='dense'`` and ``pct=True``
- Bug in :func:`pandas.core.windows.Windows.validate` where windows parameter was accpeting a numeric value of 0 (:issue:`21286`)
Copy link
Contributor

Choose a reason for hiding this comment

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

pls make this user facing, something like

Bug in :func:`pandas.DataFrame.rolling` and :func:`pandas.Series.rolling` which incorrectly accepted a 0 window size rather than raising


Strings
^^^^^^^
Expand Down
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("window must be > 0 ")
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