Skip to content

Commit

Permalink
BUG: invalid rolling window on empty input (#21291)
Browse files Browse the repository at this point in the history
  • Loading branch information
uds5501 authored and jreback committed Jun 8, 2018
1 parent 7f6ea67 commit 93be27d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
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 @@ -53,6 +53,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.DataFrame.rolling` and :func:`pandas.Series.rolling` which incorrectly accepted a 0 window size rather than raising (:issue:`21286`)

Data-type specific
~~~~~~~~~~~~~~~~~~
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

0 comments on commit 93be27d

Please sign in to comment.