@@ -441,6 +441,20 @@ def test_closed(self):
441441 with pytest .raises (ValueError ):
442442 df .rolling (window = 3 , closed = 'neither' )
443443
444+ @pytest .mark .parametrize ('roller' , ['1s' , 1 ])
445+ def tests_empty_df_rolling (self , roller ):
446+ # GH 15819 Verifies that datetime and integer rolling windows can be
447+ # applied to empty DataFrames
448+ expected = DataFrame ()
449+ result = DataFrame ().rolling (roller ).sum ()
450+ tm .assert_frame_equal (result , expected )
451+
452+ # Verifies that datetime and integer rolling windows can be applied to
453+ # empty DataFrames with datetime index
454+ expected = DataFrame (index = pd .DatetimeIndex ([]))
455+ result = DataFrame (index = pd .DatetimeIndex ([])).rolling (roller ).sum ()
456+ tm .assert_frame_equal (result , expected )
457+
444458
445459class TestExpanding (Base ):
446460
@@ -483,6 +497,24 @@ def test_numpy_compat(self):
483497 tm .assert_raises_regex (UnsupportedFunctionCall , msg ,
484498 getattr (e , func ), dtype = np .float64 )
485499
500+ @pytest .mark .parametrize (
501+ 'expander' ,
502+ [1 , pytest .mark .xfail (
503+ reason = 'GH 16425 expanding with offset not supported' )('1s' )])
504+ def tests_empty_df_expanding (self , expander ):
505+ # GH 15819 Verifies that datetime and integer expanding windows can be
506+ # applied to empty DataFrames
507+ expected = DataFrame ()
508+ result = DataFrame ().expanding (expander ).sum ()
509+ tm .assert_frame_equal (result , expected )
510+
511+ # Verifies that datetime and integer expanding windows can be applied
512+ # to empty DataFrames with datetime index
513+ expected = DataFrame (index = pd .DatetimeIndex ([]))
514+ result = DataFrame (
515+ index = pd .DatetimeIndex ([])).expanding (expander ).sum ()
516+ tm .assert_frame_equal (result , expected )
517+
486518
487519class TestEWM (Base ):
488520
0 commit comments