Skip to content

Commit 4e59555

Browse files
tptopper-123
tp
authored andcommitted
changes according to comments
1 parent 1df2808 commit 4e59555

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

doc/source/whatsnew/v0.23.4.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Bug Fixes
3232

3333
- Bug where calling :func:`DataFrameGroupBy.agg` with a list of functions including ``ohlc`` as the non-initial element would raise a ``ValueError`` (:issue:`21716`)
3434
- Bug in ``roll_quantile`` caused a memory leak when calling ``.rolling(...).quantile(q)`` with ``q`` in (0,1) (:issue:`21965`)
35-
- Bug in :func:`pandas.core.groupby.SeriesGroupBy.count` when using numpy < 1.13 and ngroups=0 (:issue:`21956`).
35+
- Bug where ``ValueError`` is wrongly raised when calling :func:`~pandas.core.groupby.SeriesGroupBy.count` method of a
36+
``SeriesGroupBy`` when the grouping variable only contains NaNs and numpy version < 1.13 (:issue:`21956`).
3637
-
3738

3839
**Conversion**

pandas/core/groupby/generic.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
from pandas.core.index import Index, MultiIndex, CategoricalIndex
4747
from pandas.core.arrays.categorical import Categorical
4848
from pandas.core.internals import BlockManager, make_block
49-
from pandas.compat.numpy import _np_version_under1p13
5049

5150
from pandas.plotting._core import boxplot_frame_groupby
5251

@@ -1208,10 +1207,7 @@ def count(self):
12081207

12091208
mask = (ids != -1) & ~isna(val)
12101209
ids = ensure_platform_int(ids)
1211-
minlength = ngroups or 0
1212-
if _np_version_under1p13 and minlength == 0:
1213-
minlength = None
1214-
out = np.bincount(ids[mask], minlength=minlength)
1210+
out = np.bincount(ids[mask], minlength=ngroups or None)
12151211

12161212
return Series(out,
12171213
index=self.grouper.result_index,

0 commit comments

Comments
 (0)