@@ -610,6 +610,33 @@ def test_list_grouper_with_nat(self):
610
610
expected = {pd .Timestamp ("2011-01-01" ): 365 }
611
611
tm .assert_dict_equal (result .groups , expected )
612
612
613
+ @pytest .mark .parametrize (
614
+ "func,expected" ,
615
+ [
616
+ (
617
+ "transform" ,
618
+ pd .Series (name = 2 , dtype = np .float64 , index = pd .Index ([], dtype = "object" )),
619
+ ),
620
+ (
621
+ "agg" ,
622
+ pd .Series (name = 2 , dtype = np .float64 , index = pd .Float64Index ([], name = 1 )),
623
+ ),
624
+ (
625
+ "apply" ,
626
+ pd .Series (name = 2 , dtype = np .float64 , index = pd .Float64Index ([], name = 1 )),
627
+ ),
628
+ ],
629
+ )
630
+ def test_evaluate_with_empty_groups (self , func , expected ):
631
+ # 26208
632
+ # test transform'ing empty groups
633
+ # (not testing other agg fns, because they return
634
+ # different index objects.
635
+ df = pd .DataFrame ({1 : [], 2 : []})
636
+ g = df .groupby (1 )
637
+ result = getattr (g [2 ], func )(lambda x : x )
638
+ tm .assert_series_equal (result , expected )
639
+
613
640
def test_groupby_empty (self ):
614
641
# https://github.com/pandas-dev/pandas/issues/27190
615
642
s = pd .Series ([], name = "name" , dtype = "float64" )
0 commit comments