From 5c348ed4f290822c1be985f2c3ae8262131814ec Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 7 Mar 2019 12:54:41 +0000 Subject: [PATCH] TST: add test for groupby on list of empty list --- pandas/tests/groupby/test_groupby.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index 6a11f0ae9b44a..c062fb90ca43b 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -1714,3 +1714,12 @@ def test_groupby_multiindex_nat(): result = ser.groupby(level=1).mean() expected = pd.Series([3., 2.5], index=["a", "b"]) assert_series_equal(result, expected) + + +def test_groupby_empty_list_raises(): + # GH 5289 + values = zip(range(10), range(10)) + df = DataFrame(values, columns=['apple', 'b']) + msg = "Grouper and axis must be same length" + with pytest.raises(ValueError, match=msg): + df.groupby([[]])