@@ -1359,9 +1359,34 @@ def test_resample_empty(self):
1359
1359
# (ex: doing mean with dtype of np.object)
1360
1360
pass
1361
1361
1362
- # this should also tests nunique (IOW, use resample_methods)
1362
+ # this should also tests nunique
1363
+ # (IOW, use resample_methods)
1363
1364
# when GH12886 is closed
1364
1365
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
+
1365
1390
def test_resample_dtype_preservation (self ):
1366
1391
1367
1392
# GH 12202
0 commit comments