-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsRefactorInternal refactoring of codeInternal refactoring of code
Description
From #42085 (comment), for groupby any/all we have bool coercing logic in
pandas/pandas/core/groupby/groupby.py
Lines 1521 to 1526 in 6ca8757
if is_object_dtype(vals): | |
# GH#37501: don't raise on pd.NA when skipna=True | |
if skipna: | |
vals = np.array([bool(x) if not isna(x) else True for x in vals]) | |
else: | |
vals = np.array([bool(x) for x in vals]) |
Would be nice to share this with handling in
Lines 534 to 539 in 6ca8757
values, _, _, _, _ = _get_values(values, skipna, fill_value=True, mask=mask) | |
# For object type, all won't necessarily return | |
# boolean values (numpy/numpy#4352) | |
if is_object_dtype(values): | |
values = values.astype(bool) |
though complicated by shape requirement differences and the complicated nature of
_get_values
Metadata
Metadata
Assignees
Labels
AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsRefactorInternal refactoring of codeInternal refactoring of code