@@ -91,27 +91,15 @@ def test_nested_renamer(box, method, func):
91
91
getattr (obj , method )(func )
92
92
93
93
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 ):
103
99
s = Series (range (6 ), dtype = "int64" , name = "series" )
104
- # nested renaming
105
100
msg = "nested renamer is not supported"
106
101
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 )
115
103
116
104
117
105
def test_agg_dict_nested_renaming_depr_agg ():
@@ -156,14 +144,6 @@ def test_missing_column(method, func):
156
144
getattr (obj , method )(func )
157
145
158
146
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
-
167
147
def test_transform_mixed_column_name_dtypes ():
168
148
# GH39025
169
149
df = DataFrame ({"a" : ["1" ]})
@@ -328,14 +308,8 @@ def test_transform_and_agg_err_agg(axis, float_frame):
328
308
with np .errstate (all = "ignore" ):
329
309
float_frame .agg (["max" , "sqrt" ], axis = axis )
330
310
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
-
337
311
338
- def test_transform_and_agg_error_agg (string_series ):
312
+ def test_transform_and_agg_err_series (string_series ):
339
313
# we are trying to transform with an aggregator
340
314
msg = "cannot combine transform and aggregation"
341
315
with pytest .raises (ValueError , match = msg ):
@@ -348,7 +322,7 @@ def test_transform_and_agg_error_agg(string_series):
348
322
string_series .agg ({"foo" : np .sqrt , "bar" : "sum" })
349
323
350
324
351
- def test_transform_and_agg_err_transform (axis , float_frame ):
325
+ def test_transform_and_agg_err_frame (axis , float_frame ):
352
326
# GH 35964
353
327
# cannot both transform and agg
354
328
msg = "Function did not transform"
0 commit comments