Skip to content

Commit 689ae3d

Browse files
committed
Add test to check numeric precision GH33234
Signed-off-by: Liang Yan <ckgppl_yan@sina.cn>
1 parent d9ba285 commit 689ae3d

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
@@ -1367,6 +1367,43 @@ def func(ser):
13671367
tm.assert_frame_equal(res, expected)
13681368

13691369

1370+
@pytest.mark.parametrize(
1371+
"dtype",
1372+
[
1373+
"int64",
1374+
"uint64",
1375+
"int32",
1376+
"uint32",
1377+
"float64",
1378+
"float32",
1379+
"Int64",
1380+
"UInt64",
1381+
"Int32",
1382+
"UInt32",
1383+
"Float64",
1384+
"Float32",
1385+
],
1386+
)
1387+
def test_groupby_agg_precision(dtype):
1388+
# GH33234
1389+
df = DataFrame(
1390+
{
1391+
"key1": ["a"],
1392+
"key2": ["b"],
1393+
"key3": [
1394+
1583715738627261039
1395+
if dtype not in ["int32", "uint32", "Int32", "UInt32"]
1396+
else 4294967295
1397+
if dtype in ["uint32", "UInt32"]
1398+
else 2147483647
1399+
],
1400+
}
1401+
).astype({"key3": dtype})
1402+
expected = df[["key3"]]
1403+
result = df.groupby(["key1", "key2"]).agg(lambda x: x).reset_index()[["key3"]]
1404+
tm.assert_frame_equal(result, expected)
1405+
1406+
13701407
def test_groupby_aggregate_directory(reduction_func):
13711408
# GH#32793
13721409
if reduction_func in ["corrwith", "nth"]:

0 commit comments

Comments
 (0)