File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
pandas/tests/groupby/aggregate Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1377,6 +1377,33 @@ def func(ser):
13771377 tm .assert_frame_equal (res , expected )
13781378
13791379
1380+ def test_groupby_agg_precision (any_real_numeric_dtype ):
1381+ if any_real_numeric_dtype in tm .ALL_INT_NUMPY_DTYPES :
1382+ max_value = np .iinfo (any_real_numeric_dtype ).max
1383+ if any_real_numeric_dtype in tm .FLOAT_NUMPY_DTYPES :
1384+ max_value = np .finfo (any_real_numeric_dtype ).max
1385+ if any_real_numeric_dtype in tm .FLOAT_EA_DTYPES :
1386+ max_value = np .finfo (any_real_numeric_dtype .lower ()).max
1387+ if any_real_numeric_dtype in tm .ALL_INT_EA_DTYPES :
1388+ max_value = np .iinfo (any_real_numeric_dtype .lower ()).max
1389+
1390+ df = DataFrame (
1391+ {
1392+ "key1" : ["a" ],
1393+ "key2" : ["b" ],
1394+ "key3" : pd .array ([max_value ], dtype = any_real_numeric_dtype ),
1395+ }
1396+ )
1397+ arrays = [["a" ], ["b" ]]
1398+ index = MultiIndex .from_arrays (arrays , names = ("key1" , "key2" ))
1399+
1400+ expected = DataFrame (
1401+ {"key3" : pd .array ([max_value ], dtype = any_real_numeric_dtype )}, index = index
1402+ )
1403+ result = df .groupby (["key1" , "key2" ]).agg (lambda x : x )
1404+ tm .assert_frame_equal (result , expected )
1405+
1406+
13801407def test_groupby_aggregate_directory (reduction_func ):
13811408 # GH#32793
13821409 if reduction_func in ["corrwith" , "nth" ]:
You can’t perform that action at this time.
0 commit comments