@@ -250,10 +250,10 @@ def test_agg_str_with_kwarg_axis_1_raises(df, reduction_func):
250
250
"func, expected, dtype, result_dtype_dict" ,
251
251
[
252
252
("sum" , [5 , 7 , 9 ], "int64" , {}),
253
- ("std" , [4.5 ** 0.5 ] * 3 , int , {"i" : float , "j" : float , "k" : float }),
253
+ ("std" , [4.5 ** 0.5 ] * 3 , int , {"i" : float , "j" : float , "k" : float }),
254
254
("var" , [4.5 ] * 3 , int , {"i" : float , "j" : float , "k" : float }),
255
255
("sum" , [5 , 7 , 9 ], "Int64" , {"j" : "int64" }),
256
- ("std" , [4.5 ** 0.5 ] * 3 , "Int64" , {"i" : float , "j" : float , "k" : float }),
256
+ ("std" , [4.5 ** 0.5 ] * 3 , "Int64" , {"i" : float , "j" : float , "k" : float }),
257
257
("var" , [4.5 ] * 3 , "Int64" , {"i" : "float64" , "j" : "float64" , "k" : "float64" }),
258
258
],
259
259
)
@@ -280,7 +280,7 @@ def test_multiindex_groupby_mixed_cols_axis1(func, expected, dtype, result_dtype
280
280
[
281
281
("sum" , [[2 , 4 ], [10 , 12 ], [18 , 20 ]], {10 : "int64" , 20 : "int64" }),
282
282
# std should ideally return Int64 / Float64 #43330
283
- ("std" , [[2 ** 0.5 ] * 2 ] * 3 , "float64" ),
283
+ ("std" , [[2 ** 0.5 ] * 2 ] * 3 , "float64" ),
284
284
("var" , [[2 ] * 2 ] * 3 , {10 : "float64" , 20 : "float64" }),
285
285
],
286
286
)
@@ -524,8 +524,7 @@ def test_groupby_agg_dict_with_getitem():
524
524
def test_groupby_agg_dict_dup_columns ():
525
525
# GH#55006
526
526
df = DataFrame (
527
- [[1 , 2 , 3 , 4 ], [1 , 3 , 4 , 5 ], [2 , 4 , 5 , 6 ]],
528
- columns = ["a" , "b" , "c" , "c" ],
527
+ [[1 , 2 , 3 , 4 ], [1 , 3 , 4 , 5 ], [2 , 4 , 5 , 6 ]], columns = ["a" , "b" , "c" , "c" ],
529
528
)
530
529
gb = df .groupby ("a" )
531
530
result = gb .agg ({"b" : "sum" })
@@ -889,11 +888,12 @@ def f(x):
889
888
raise ValueError ("length must not be 0" )
890
889
return len (x )
891
890
892
- df = DataFrame ({"A" : pd .Categorical (['a' , 'a' ],
893
- categories = ['a' , 'b' , 'c' ]), "B" : [1 , 1 ]})
894
- msg = 'length must not be 0'
891
+ df = DataFrame (
892
+ {"A" : pd .Categorical (["a" , "a" ], categories = ["a" , "b" , "c" ]), "B" : [1 , 1 ]}
893
+ )
894
+ msg = "length must not be 0"
895
895
with pytest .raises (ValueError , match = msg ):
896
- df .groupby ('A' ).agg (f )
896
+ df .groupby ("A" ).agg (f )
897
897
898
898
def test_agg_namedtuple (self ):
899
899
df = DataFrame ({"A" : [0 , 1 ], "B" : [1 , 2 ]})
@@ -1198,7 +1198,7 @@ def test_agg_with_one_lambda(self):
1198
1198
# check pd.NameAgg case
1199
1199
result1 = df .groupby (by = "kind" ).agg (
1200
1200
height_sqr_min = pd .NamedAgg (
1201
- column = "height" , aggfunc = lambda x : np .min (x ** 2 )
1201
+ column = "height" , aggfunc = lambda x : np .min (x ** 2 )
1202
1202
),
1203
1203
height_max = pd .NamedAgg (column = "height" , aggfunc = "max" ),
1204
1204
weight_max = pd .NamedAgg (column = "weight" , aggfunc = "max" ),
@@ -1207,7 +1207,7 @@ def test_agg_with_one_lambda(self):
1207
1207
1208
1208
# check agg(key=(col, aggfunc)) case
1209
1209
result2 = df .groupby (by = "kind" ).agg (
1210
- height_sqr_min = ("height" , lambda x : np .min (x ** 2 )),
1210
+ height_sqr_min = ("height" , lambda x : np .min (x ** 2 )),
1211
1211
height_max = ("height" , "max" ),
1212
1212
weight_max = ("weight" , "max" ),
1213
1213
)
@@ -1244,7 +1244,7 @@ def test_agg_multiple_lambda(self):
1244
1244
1245
1245
# check agg(key=(col, aggfunc)) case
1246
1246
result1 = df .groupby (by = "kind" ).agg (
1247
- height_sqr_min = ("height" , lambda x : np .min (x ** 2 )),
1247
+ height_sqr_min = ("height" , lambda x : np .min (x ** 2 )),
1248
1248
height_max = ("height" , "max" ),
1249
1249
weight_max = ("weight" , "max" ),
1250
1250
height_max_2 = ("height" , lambda x : np .max (x )),
@@ -1255,7 +1255,7 @@ def test_agg_multiple_lambda(self):
1255
1255
# check pd.NamedAgg case
1256
1256
result2 = df .groupby (by = "kind" ).agg (
1257
1257
height_sqr_min = pd .NamedAgg (
1258
- column = "height" , aggfunc = lambda x : np .min (x ** 2 )
1258
+ column = "height" , aggfunc = lambda x : np .min (x ** 2 )
1259
1259
),
1260
1260
height_max = pd .NamedAgg (column = "height" , aggfunc = "max" ),
1261
1261
weight_max = pd .NamedAgg (column = "weight" , aggfunc = "max" ),
0 commit comments