@@ -91,27 +91,15 @@ def test_nested_renamer(box, method, func):
9191 getattr (obj , method )(func )
9292
9393
94- def test_series_agg_nested_renamer ():
95- s = Series (range (6 ), dtype = "int64" , name = "series" )
96- msg = "nested renamer is not supported"
97- with pytest .raises (SpecificationError , match = msg ):
98- s .agg ({"foo" : ["min" , "max" ]})
99-
100-
101- def test_multiple_aggregators_with_dict_api ():
102-
94+ @pytest .mark .parametrize (
95+ "renamer" ,
96+ [{"foo" : ["min" , "max" ]}, {"foo" : ["min" , "max" ], "bar" : ["sum" , "mean" ]}],
97+ )
98+ def test_series_nested_renamer (renamer ):
10399 s = Series (range (6 ), dtype = "int64" , name = "series" )
104- # nested renaming
105100 msg = "nested renamer is not supported"
106101 with pytest .raises (SpecificationError , match = msg ):
107- s .agg ({"foo" : ["min" , "max" ], "bar" : ["sum" , "mean" ]})
108-
109-
110- def test_transform_nested_renamer ():
111- # GH 35964
112- match = "nested renamer is not supported"
113- with pytest .raises (SpecificationError , match = match ):
114- Series ([1 ]).transform ({"A" : {"B" : ["sum" ]}})
102+ s .agg (renamer )
115103
116104
117105def test_agg_dict_nested_renaming_depr_agg ():
@@ -156,14 +144,6 @@ def test_missing_column(method, func):
156144 getattr (obj , method )(func )
157145
158146
159- def test_transform_missing_columns (axis ):
160- # GH#35964
161- df = DataFrame ({"A" : [1 , 2 ], "B" : [3 , 4 ]})
162- match = re .escape ("Column(s) ['C'] do not exist" )
163- with pytest .raises (KeyError , match = match ):
164- df .transform ({"C" : "cumsum" })
165-
166-
167147def test_transform_mixed_column_name_dtypes ():
168148 # GH39025
169149 df = DataFrame ({"a" : ["1" ]})
@@ -328,14 +308,8 @@ def test_transform_and_agg_err_agg(axis, float_frame):
328308 with np .errstate (all = "ignore" ):
329309 float_frame .agg (["max" , "sqrt" ], axis = axis )
330310
331- df = DataFrame ({"A" : range (5 ), "B" : 5 })
332-
333- def f ():
334- with np .errstate (all = "ignore" ):
335- df .agg ({"A" : ["abs" , "sum" ], "B" : ["mean" , "max" ]}, axis = axis )
336-
337311
338- def test_transform_and_agg_error_agg (string_series ):
312+ def test_transform_and_agg_err_series (string_series ):
339313 # we are trying to transform with an aggregator
340314 msg = "cannot combine transform and aggregation"
341315 with pytest .raises (ValueError , match = msg ):
@@ -348,7 +322,7 @@ def test_transform_and_agg_error_agg(string_series):
348322 string_series .agg ({"foo" : np .sqrt , "bar" : "sum" })
349323
350324
351- def test_transform_and_agg_err_transform (axis , float_frame ):
325+ def test_transform_and_agg_err_frame (axis , float_frame ):
352326 # GH 35964
353327 # cannot both transform and agg
354328 msg = "Function did not transform"
0 commit comments