@@ -247,6 +247,41 @@ def test_dataframe_groupby_agg_named(scalars_df_index, scalars_pandas_df_index):
247247 pd .testing .assert_frame_equal (pd_result , bf_result_computed , check_dtype = False )
248248
249249
250+ def test_dataframe_groupby_agg_kw_tuples (scalars_df_index , scalars_pandas_df_index ):
251+ col_names = ["int64_too" , "float64_col" , "int64_col" , "bool_col" , "string_col" ]
252+ bf_result = (
253+ scalars_df_index [col_names ]
254+ .groupby ("string_col" )
255+ .agg (
256+ agg1 = ("int64_too" , "sum" ),
257+ agg2 = ("float64_col" , "max" ),
258+ )
259+ )
260+ pd_result = (
261+ scalars_pandas_df_index [col_names ]
262+ .groupby ("string_col" )
263+ .agg (agg1 = ("int64_too" , "sum" ), agg2 = ("float64_col" , "max" ))
264+ )
265+ bf_result_computed = bf_result .to_pandas ()
266+
267+ pd .testing .assert_frame_equal (pd_result , bf_result_computed , check_dtype = False )
268+
269+
270+ @pytest .mark .parametrize (
271+ ("kwargs" ),
272+ [
273+ ({"hello" : "world" }),
274+ ({"too_many_fields" : ("one" , "two" , "three" )}),
275+ ],
276+ )
277+ def test_dataframe_groupby_agg_kw_error (scalars_df_index , kwargs ):
278+ col_names = ["int64_too" , "float64_col" , "int64_col" , "bool_col" , "string_col" ]
279+ with pytest .raises (
280+ TypeError , match = r"kwargs values must be 2-tuples of column, aggfunc"
281+ ):
282+ (scalars_df_index [col_names ].groupby ("string_col" ).agg (** kwargs ))
283+
284+
250285@pytest .mark .parametrize (
251286 ("as_index" ),
252287 [
0 commit comments