Skip to content

Commit ab4ae04

Browse files
aram-cedarwoodcbpygit
authored andcommitted
Add test groupby complex numbers (pandas-dev#56570)
1 parent a318356 commit ab4ae04

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/groupby/test_groupby.py

+18
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,24 @@ def test_groupby_complex():
11961196
tm.assert_series_equal(result, expected)
11971197

11981198

1199+
def test_groupby_complex_mean():
1200+
# GH 26475
1201+
df = DataFrame(
1202+
[
1203+
{"a": 2, "b": 1 + 2j},
1204+
{"a": 1, "b": 1 + 1j},
1205+
{"a": 1, "b": 1 + 2j},
1206+
]
1207+
)
1208+
result = df.groupby("b").mean()
1209+
expected = DataFrame(
1210+
[[1.0], [1.5]],
1211+
index=Index([(1 + 1j), (1 + 2j)], name="b"),
1212+
columns=Index(["a"]),
1213+
)
1214+
tm.assert_frame_equal(result, expected)
1215+
1216+
11991217
def test_groupby_complex_numbers(using_infer_string):
12001218
# GH 17927
12011219
df = DataFrame(

0 commit comments

Comments
 (0)