Skip to content

CLN: simplify get_values usage in groupby #32523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
is_scalar,
needs_i8_conversion,
)
from pandas.core.dtypes.missing import _isna_ndarraylike, isna, notna
from pandas.core.dtypes.missing import isna, notna

from pandas.core.aggregation import (
is_multi_agg_with_relabel,
Expand Down Expand Up @@ -1772,10 +1772,8 @@ def count(self):
ids, _, ngroups = self.grouper.group_info
mask = ids != -1

vals = (
(mask & ~_isna_ndarraylike(np.atleast_2d(blk.get_values())))
for blk in data.blocks
)
# TODO(2DEA): reshape would not be necessary with 2D EAs
vals = ((mask & ~isna(blk.values).reshape(blk.shape)) for blk in data.blocks)
locs = (blk.mgr_locs for blk in data.blocks)

counted = (
Expand Down