Skip to content

Commit f4cd453

Browse files
committed
Add test code
1 parent 4554352 commit f4cd453

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/extension/test_arrow.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,6 +3257,27 @@ def test_groupby_count_return_arrow_dtype(data_missing):
32573257
tm.assert_frame_equal(result, expected)
32583258

32593259

3260+
@pytest.mark.parametrize(
3261+
"func, func_dtype",
3262+
[
3263+
[lambda x: x.to_dict(), "object"],
3264+
[lambda x: 1, "int64"],
3265+
[lambda x: "s", ArrowDtype(pa.string())],
3266+
],
3267+
)
3268+
def test_groupby_aggregate_coersion(func, func_dtype):
3269+
# GH 61636
3270+
df = pd.DataFrame(
3271+
{
3272+
"b": pd.array([0, 1]),
3273+
"c": pd.array(["X", "Y"], dtype=ArrowDtype(pa.string())),
3274+
},
3275+
index=pd.Index(["A", "B"], name="a"),
3276+
)
3277+
result = df.groupby("b").agg(func)
3278+
assert result["c"].dtype == func_dtype
3279+
3280+
32603281
def test_fixed_size_list():
32613282
# GH#55000
32623283
ser = pd.Series(

0 commit comments

Comments
 (0)