Skip to content

REF: consolidate object dtype handling for any/all #42175

Closed
@mzeitlin11

Description

@mzeitlin11

From #42085 (comment), for groupby any/all we have bool coercing logic in

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

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

No one assigned

    Labels

    AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffDtype ConversionsUnexpected or buggy dtype conversionsRefactorInternal refactoring of code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions