1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import numpy as np
1516import pandas as pd
1617import pytest
1718
@@ -223,7 +224,7 @@ def test_dataframe_groupby_agg_list(scalars_df_index, scalars_pandas_df_index):
223224 pd_result = (
224225 scalars_pandas_df_index [col_names ]
225226 .groupby ("string_col" )
226- .agg (["count" , " min" , "size" ])
227+ .agg (["count" , np . min , "size" ])
227228 )
228229 bf_result_computed = bf_result .to_pandas ()
229230
@@ -240,8 +241,8 @@ def test_dataframe_groupby_agg_list_w_column_multi_index(
240241 pd_df = scalars_pandas_df_index [columns ].copy ()
241242 pd_df .columns = multi_columns
242243
243- bf_result = bf_df .groupby (level = 0 ).agg (["count" , " min" , "size" ])
244- pd_result = pd_df .groupby (level = 0 ).agg (["count" , " min" , "size" ])
244+ bf_result = bf_df .groupby (level = 0 ).agg (["count" , np . min , "size" ])
245+ pd_result = pd_df .groupby (level = 0 ).agg (["count" , np . min , "size" ])
245246
246247 bf_result_computed = bf_result .to_pandas ()
247248 pd .testing .assert_frame_equal (pd_result , bf_result_computed , check_dtype = False )
@@ -261,12 +262,16 @@ def test_dataframe_groupby_agg_dict_with_list(
261262 bf_result = (
262263 scalars_df_index [col_names ]
263264 .groupby ("string_col" , as_index = as_index )
264- .agg ({"int64_too" : ["mean" , "max" ], "string_col" : "count" , "bool_col" : "size" })
265+ .agg (
266+ {"int64_too" : [np .mean , np .max ], "string_col" : "count" , "bool_col" : "size" }
267+ )
265268 )
266269 pd_result = (
267270 scalars_pandas_df_index [col_names ]
268271 .groupby ("string_col" , as_index = as_index )
269- .agg ({"int64_too" : ["mean" , "max" ], "string_col" : "count" , "bool_col" : "size" })
272+ .agg (
273+ {"int64_too" : [np .mean , np .max ], "string_col" : "count" , "bool_col" : "size" }
274+ )
270275 )
271276 bf_result_computed = bf_result .to_pandas ()
272277
@@ -280,12 +285,12 @@ def test_dataframe_groupby_agg_dict_no_lists(scalars_df_index, scalars_pandas_df
280285 bf_result = (
281286 scalars_df_index [col_names ]
282287 .groupby ("string_col" )
283- .agg ({"int64_too" : " mean" , "string_col" : "count" })
288+ .agg ({"int64_too" : np . mean , "string_col" : "count" })
284289 )
285290 pd_result = (
286291 scalars_pandas_df_index [col_names ]
287292 .groupby ("string_col" )
288- .agg ({"int64_too" : " mean" , "string_col" : "count" })
293+ .agg ({"int64_too" : np . mean , "string_col" : "count" })
289294 )
290295 bf_result_computed = bf_result .to_pandas ()
291296
@@ -298,15 +303,16 @@ def test_dataframe_groupby_agg_named(scalars_df_index, scalars_pandas_df_index):
298303 scalars_df_index [col_names ]
299304 .groupby ("string_col" )
300305 .agg (
301- agg1 = bpd .NamedAgg ("int64_too" , " sum" ),
306+ agg1 = bpd .NamedAgg ("int64_too" , np . sum ),
302307 agg2 = bpd .NamedAgg ("float64_col" , "max" ),
303308 )
304309 )
305310 pd_result = (
306311 scalars_pandas_df_index [col_names ]
307312 .groupby ("string_col" )
308313 .agg (
309- agg1 = pd .NamedAgg ("int64_too" , "sum" ), agg2 = pd .NamedAgg ("float64_col" , "max" )
314+ agg1 = pd .NamedAgg ("int64_too" , np .sum ),
315+ agg2 = pd .NamedAgg ("float64_col" , "max" ),
310316 )
311317 )
312318 bf_result_computed = bf_result .to_pandas ()
@@ -320,14 +326,14 @@ def test_dataframe_groupby_agg_kw_tuples(scalars_df_index, scalars_pandas_df_ind
320326 scalars_df_index [col_names ]
321327 .groupby ("string_col" )
322328 .agg (
323- agg1 = ("int64_too" , " sum" ),
329+ agg1 = ("int64_too" , np . sum ),
324330 agg2 = ("float64_col" , "max" ),
325331 )
326332 )
327333 pd_result = (
328334 scalars_pandas_df_index [col_names ]
329335 .groupby ("string_col" )
330- .agg (agg1 = ("int64_too" , " sum" ), agg2 = ("float64_col" , "max" ))
336+ .agg (agg1 = ("int64_too" , np . sum ), agg2 = ("float64_col" , "max" ))
331337 )
332338 bf_result_computed = bf_result .to_pandas ()
333339
@@ -709,12 +715,12 @@ def test_series_groupby_agg_list(scalars_df_index, scalars_pandas_df_index):
709715 bf_result = (
710716 scalars_df_index ["int64_col" ]
711717 .groupby (scalars_df_index ["string_col" ])
712- .agg (["sum" , " mean" , "size" ])
718+ .agg (["sum" , np . mean , "size" ])
713719 )
714720 pd_result = (
715721 scalars_pandas_df_index ["int64_col" ]
716722 .groupby (scalars_pandas_df_index ["string_col" ])
717- .agg (["sum" , " mean" , "size" ])
723+ .agg (["sum" , np . mean , "size" ])
718724 )
719725 bf_result_computed = bf_result .to_pandas ()
720726
0 commit comments