Skip to content

Commit 92a9b7b

Browse files
committed
Add test to check numeric precision GH33234
Signed-off-by: Liang Yan <ckgppl_yan@sina.cn>
1 parent 178e504 commit 92a9b7b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

pandas/tests/groupby/aggregate/test_aggregate.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,43 @@ def func(ser):
13771377
tm.assert_frame_equal(res, expected)
13781378

13791379

1380+
@pytest.mark.parametrize(
1381+
"dtype",
1382+
[
1383+
"int64",
1384+
"uint64",
1385+
"int32",
1386+
"uint32",
1387+
"float64",
1388+
"float32",
1389+
"Int64",
1390+
"UInt64",
1391+
"Int32",
1392+
"UInt32",
1393+
"Float64",
1394+
"Float32",
1395+
],
1396+
)
1397+
def test_groupby_agg_precision(dtype):
1398+
# GH33234
1399+
df = DataFrame(
1400+
{
1401+
"key1": ["a"],
1402+
"key2": ["b"],
1403+
"key3": [
1404+
pd.array([1583715738627261039], dtype=dtype)[0]
1405+
if dtype not in ["int32", "uint32", "Int32", "UInt32"]
1406+
else pd.array([4294967295], dtype=dtype)[0]
1407+
if dtype in ["uint32", "UInt32"]
1408+
else pd.array([2147483647], dtype=dtype)[0]
1409+
],
1410+
}
1411+
)
1412+
expected = df[["key3"]]
1413+
result = df.groupby(["key1", "key2"]).agg(lambda x: x).reset_index()[["key3"]]
1414+
tm.assert_frame_equal(result, expected)
1415+
1416+
13801417
def test_groupby_aggregate_directory(reduction_func):
13811418
# GH#32793
13821419
if reduction_func in ["corrwith", "nth"]:

0 commit comments

Comments
 (0)