@@ -814,6 +814,42 @@ def f(x):
814814 assert_eq (L [- 1 ], f (last ))
815815
816816
817+ def test_windowing_value_empty_intermediate_index (stream ):
818+ def preprocess (df ):
819+ mask = df ["amount" ] == 5
820+ df = df .loc [mask ]
821+ return df
822+
823+ source = stream .map (preprocess )
824+
825+ example = pd .DataFrame ({"amount" :[]})
826+ sdf = DataFrame (stream = source , example = example )
827+
828+ output = sdf .window ("2h" ).amount .sum ().stream .gather ().sink_to_list ()
829+
830+ stream .emit (pd .DataFrame ({"amount" : [1 , 2 , 3 ]}, index = [pd .Timestamp ("2050-01-01 00:00:00" ),
831+ pd .Timestamp ("2050-01-01 01:00:00" ),
832+ pd .Timestamp ("2050-01-01 02:00:00" )]))
833+
834+ stream .emit (pd .DataFrame ({"amount" : [5 , 5 , 5 ]}, index = [pd .Timestamp ("2050-01-01 03:00:00" ),
835+ pd .Timestamp ("2050-01-01 04:00:00" ),
836+ pd .Timestamp ("2050-01-01 05:00:00" )]))
837+
838+ stream .emit (pd .DataFrame ({"amount" : [4 , 5 , 6 ]}, index = [pd .Timestamp ("2050-01-01 06:00:00" ),
839+ pd .Timestamp ("2050-01-01 07:00:00" ),
840+ pd .Timestamp ("2050-01-01 08:00:00" )]))
841+
842+ stream .emit (pd .DataFrame ({"amount" : [1 , 2 , 3 ]}, index = [pd .Timestamp ("2050-01-01 09:00:00" ),
843+ pd .Timestamp ("2050-01-01 10:00:00" ),
844+ pd .Timestamp ("2050-01-01 11:00:00" )]))
845+
846+ stream .emit (pd .DataFrame ({"amount" : [5 , 5 , 5 ]}, index = [pd .Timestamp ("2050-01-01 12:00:00" ),
847+ pd .Timestamp ("2050-01-01 13:00:00" ),
848+ pd .Timestamp ("2050-01-01 14:00:00" )]))
849+
850+ assert_eq (output , [0 , 10 , 5 , 5 , 10 ])
851+
852+
817853def test_window_full ():
818854 df = pd .DataFrame ({'x' : np .arange (10 , dtype = float ), 'y' : [1.0 , 2.0 ] * 5 })
819855
0 commit comments