@@ -441,6 +441,20 @@ def test_closed(self):
441
441
with pytest .raises (ValueError ):
442
442
df .rolling (window = 3 , closed = 'neither' )
443
443
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
+
444
458
445
459
class TestExpanding (Base ):
446
460
@@ -483,6 +497,24 @@ def test_numpy_compat(self):
483
497
tm .assert_raises_regex (UnsupportedFunctionCall , msg ,
484
498
getattr (e , func ), dtype = np .float64 )
485
499
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
+
486
518
487
519
class TestEWM (Base ):
488
520
0 commit comments