Skip to content

Commit 9754f4d

Browse files
author
y-p
committed
TST: Don't segfault when categorical groupby differs in length from series, GH3011
1 parent c682aa6 commit 9754f4d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/test_groupby.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,6 +2237,15 @@ def test_groupby_first_datetime64(self):
22372237
got_dt = result.dtype
22382238
self.assert_(issubclass(got_dt.type, np.datetime64))
22392239

2240+
def test_groupby_categorical_unequal_len(self):
2241+
import pandas as pd
2242+
#GH3011
2243+
series = Series([np.nan, np.nan, 1, 1, 2, 2, 3, 3, 4, 4])
2244+
bins = pd.cut(series.dropna(), 4)
2245+
2246+
# len(bins) != len(series) here
2247+
self.assertRaises(AssertionError,lambda : series.groupby(bins).mean())
2248+
22402249
def assert_fp_equal(a, b):
22412250
assert((np.abs(a - b) < 1e-12).all())
22422251

0 commit comments

Comments
 (0)