File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
pandas/tests/groupby/aggregate Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1807,3 +1807,17 @@ def test_groupby_aggregation_func_list_multi_index_duplicate_columns():
1807
1807
index = Index (["level1.1" , "level1.2" ]),
1808
1808
)
1809
1809
tm .assert_frame_equal (result , expected )
1810
+
1811
+ def test_groupby_aggregate_empty_builtin_sum ():
1812
+ df = pd .DataFrame (columns = ["Group" , "Data" ])
1813
+ result = df .groupby (["Group" ], as_index = False )["Data" ].agg ("sum" )
1814
+ expected = pd .DataFrame (columns = ["Group" , "Data" ])
1815
+ tm .assert_frame_equal (result , expected )
1816
+
1817
+ def test_groupby_aggregate_empty_udf ():
1818
+ def func (x ):
1819
+ return sum (x )
1820
+ df = pd .DataFrame (columns = ["Group" , "Data" ])
1821
+ result = df .groupby (["Group" ], as_index = False )["Data" ].agg (func )
1822
+ expected = pd .DataFrame (columns = ["Group" , "Data" ])
1823
+ tm .assert_frame_equal (result , expected )
You can’t perform that action at this time.
0 commit comments