BUG: Fix empty closed window issue with rolling min and max (#27140) · pandas-dev/pandas@3b3b791 (original) (raw)
`@@ -48,6 +48,12 @@ def win_types_special(request):
`
48
48
`return request.param
`
49
49
``
50
50
``
``
51
`+
@pytest.fixture(params=["sum", "mean", "median", "max", "min",
`
``
52
`+
"var", "std", "kurt", "skew"])
`
``
53
`+
def arithmetic_win_operators(request):
`
``
54
`+
return request.param
`
``
55
+
``
56
+
51
57
`class Base:
`
52
58
``
53
59
`_nan_locs = np.arange(20, 40)
`
`@@ -522,6 +528,18 @@ def test_closed(self):
`
522
528
`with pytest.raises(ValueError):
`
523
529
`df.rolling(window=3, closed='neither')
`
524
530
``
``
531
`+
@pytest.mark.parametrize("closed", ["neither", "left"])
`
``
532
`+
def test_closed_empty(self, closed, arithmetic_win_operators):
`
``
533
`+
GH 26005
`
``
534
`+
func_name = arithmetic_win_operators
`
``
535
`+
ser = pd.Series(data=np.arange(5),
`
``
536
`+
index=pd.date_range("2000", periods=5, freq="2D"))
`
``
537
`+
roll = ser.rolling("1D", closed=closed)
`
``
538
+
``
539
`+
result = getattr(roll, func_name)()
`
``
540
`+
expected = pd.Series([np.nan] * 5, index=ser.index)
`
``
541
`+
tm.assert_series_equal(result, expected)
`
``
542
+
525
543
`@pytest.mark.parametrize("func", ['min', 'max'])
`
526
544
`def test_closed_one_entry(self, func):
`
527
545
`# GH24718
`