From 8802f4474cbce29aa8d11f053d93e2a0e2204126 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Sun, 11 Jun 2017 12:22:31 -0700 Subject: [PATCH] TST: Add test for groupby mean of ints Closes gh-11199. --- pandas/tests/groupby/test_aggregate.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pandas/tests/groupby/test_aggregate.py b/pandas/tests/groupby/test_aggregate.py index d7b46e6748b99..0de263589c6d6 100644 --- a/pandas/tests/groupby/test_aggregate.py +++ b/pandas/tests/groupby/test_aggregate.py @@ -234,6 +234,27 @@ def test_agg_grouping_is_list_tuple(self): expected = grouped.mean() tm.assert_frame_equal(result, expected) + def test_aggregate_float64_no_int64(self): + # see gh-11199 + df = DataFrame({"a": [1, 2, 3, 4, 5], + "b": [1, 2, 2, 4, 5], + "c": [1, 2, 3, 4, 5]}) + + expected = DataFrame({"a": [1, 2.5, 4, 5]}, + index=[1, 2, 4, 5]) + expected.index.name = "b" + + result = df.groupby("b")[["a"]].mean() + tm.assert_frame_equal(result, expected) + + expected = DataFrame({"a": [1, 2.5, 4, 5], + "c": [1, 2.5, 4, 5]}, + index=[1, 2, 4, 5]) + expected.index.name = "b" + + result = df.groupby("b")[["a", "c"]].mean() + tm.assert_frame_equal(result, expected) + def test_aggregate_api_consistency(self): # GH 9052 # make sure that the aggregates via dict