From d2aaf0060eee64925a66b03b3c4e341cf0a074e2 Mon Sep 17 00:00:00 2001 From: topper-123 Date: Wed, 1 Aug 2018 21:49:57 +0000 Subject: [PATCH] Remove depr. warning in SeriesGroupBy.count (#22155) --- pandas/core/groupby/generic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 5b2590cfcf0100..685635fb6854dc 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -46,6 +46,7 @@ from pandas.core.index import Index, MultiIndex, CategoricalIndex from pandas.core.arrays.categorical import Categorical from pandas.core.internals import BlockManager, make_block +from pandas.compat.numpy import _np_version_under1p13 from pandas.plotting._core import boxplot_frame_groupby @@ -1206,7 +1207,8 @@ def count(self): mask = (ids != -1) & ~isna(val) ids = ensure_platform_int(ids) - out = np.bincount(ids[mask], minlength=ngroups or None) + minlength = ngroups or (None if _np_version_under1p13 else 0) + out = np.bincount(ids[mask], minlength=minlength) return Series(out, index=self.grouper.result_index,