@@ -1359,9 +1359,34 @@ def test_resample_empty(self):
13591359 # (ex: doing mean with dtype of np.object)
13601360 pass
13611361
1362- # this should also tests nunique (IOW, use resample_methods)
1362+ # this should also tests nunique
1363+ # (IOW, use resample_methods)
13631364 # when GH12886 is closed
13641365
1366+ def test_resample_segfault (self ):
1367+ # GH 8573
1368+ # segfaulting in older versions
1369+ all_wins_and_wagers = [
1370+ (1 , datetime (2013 , 10 , 1 , 16 , 20 ), 1 , 0 ),
1371+ (2 , datetime (2013 , 10 , 1 , 16 , 10 ), 1 , 0 ),
1372+ (2 , datetime (2013 , 10 , 1 , 18 , 15 ), 1 , 0 ),
1373+ (2 , datetime (2013 , 10 , 1 , 16 , 10 , 31 ), 1 , 0 )]
1374+
1375+ df = pd .DataFrame .from_records (all_wins_and_wagers ,
1376+ columns = ("ID" , "timestamp" , "A" , "B" )
1377+ ).set_index ("timestamp" )
1378+ result = df .groupby ("ID" ).resample ("5min" ).sum ()
1379+ expected = DataFrame ([[1 , 1 , 0 ],
1380+ [4 , 2 , 0 ],
1381+ [2 , 1 , 0 ]],
1382+ index = pd .MultiIndex .from_tuples ([
1383+ (1 , pd .Timestamp ('2013-10-01 16:20:00' )),
1384+ (2 , pd .Timestamp ('2013-10-01 16:10:00' )),
1385+ (2 , pd .Timestamp ('2013-10-01 18:15:00' ))],
1386+ names = ['ID' , 'timestamp' ]),
1387+ columns = ['ID' , 'A' , 'B' ])
1388+ assert_frame_equal (result , expected )
1389+
13651390 def test_resample_dtype_preservation (self ):
13661391
13671392 # GH 12202
0 commit comments