Skip to content

Commit 5a6f50d

Browse files
gfyoungjreback
authored andcommitted
TST: Add test for groupby mean of ints (#16670)
Closes gh-11199.
1 parent 18a428d commit 5a6f50d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/groupby/test_aggregate.py

+21
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,27 @@ def test_agg_grouping_is_list_tuple(self):
234234
expected = grouped.mean()
235235
tm.assert_frame_equal(result, expected)
236236

237+
def test_aggregate_float64_no_int64(self):
238+
# see gh-11199
239+
df = DataFrame({"a": [1, 2, 3, 4, 5],
240+
"b": [1, 2, 2, 4, 5],
241+
"c": [1, 2, 3, 4, 5]})
242+
243+
expected = DataFrame({"a": [1, 2.5, 4, 5]},
244+
index=[1, 2, 4, 5])
245+
expected.index.name = "b"
246+
247+
result = df.groupby("b")[["a"]].mean()
248+
tm.assert_frame_equal(result, expected)
249+
250+
expected = DataFrame({"a": [1, 2.5, 4, 5],
251+
"c": [1, 2.5, 4, 5]},
252+
index=[1, 2, 4, 5])
253+
expected.index.name = "b"
254+
255+
result = df.groupby("b")[["a", "c"]].mean()
256+
tm.assert_frame_equal(result, expected)
257+
237258
def test_aggregate_api_consistency(self):
238259
# GH 9052
239260
# make sure that the aggregates via dict

0 commit comments

Comments
 (0)