@@ -444,10 +444,34 @@ def test_grouper_creation_bug(self):
444
444
445
445
# GH14334
446
446
# pd.Grouper(key=...) may be passed in a list
447
+ df = DataFrame ({'A' : [0 , 0 , 0 , 1 , 1 , 1 ],
448
+ 'B' : [1 , 1 , 2 , 2 , 3 , 3 ],
449
+ 'C' : [1 , 2 , 3 , 4 , 5 , 6 ]})
450
+ # Group by single column
451
+ expected = df .groupby ('A' ).sum ()
447
452
g = df .groupby ([pd .Grouper (key = 'A' )])
448
453
result = g .sum ()
449
454
assert_frame_equal (result , expected )
450
455
456
+ # Group by two columns
457
+ # using a combination of strings and Grouper objects
458
+ expected = df .groupby (['A' , 'B' ]).sum ()
459
+
460
+ # Group with two Grouper objects
461
+ g = df .groupby ([pd .Grouper (key = 'A' ), pd .Grouper (key = 'B' )])
462
+ result = g .sum ()
463
+ assert_frame_equal (result , expected )
464
+
465
+ # Group with a string and a Grouper object
466
+ g = df .groupby (['A' , pd .Grouper (key = 'B' )])
467
+ result = g .sum ()
468
+ assert_frame_equal (result , expected )
469
+
470
+ # Group with a Grouper object and a string
471
+ g = df .groupby ([pd .Grouper (key = 'A' ), 'B' ])
472
+ result = g .sum ()
473
+ assert_frame_equal (result , expected )
474
+
451
475
# GH8866
452
476
s = Series (np .arange (8 , dtype = 'int64' ),
453
477
index = pd .MultiIndex .from_product (
0 commit comments