Skip to content

PERF: avoid casting to float in IntegerArray reducing ops #30436

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

Currently, we cast to float in the IntegerArray reducing ops:

# coerce to a nan-aware float if needed
if mask.any():
data = self._data.astype("float64")
data[mask] = self._na_value
op = getattr(nanops, "nan" + name)

However, the nanops functions can already handle a mask. So with the appropriate fill_value, there should be no need to cast the integers to float (and check for missing values). At least this is the case for skipna=True, the case of skipna=False might need to be handled separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExtensionArrayExtending pandas with custom dtypes or arrays.NA - MaskedArraysRelated to pd.NA and nullable extension arraysPerformanceMemory or execution speed performanceReduction Operationssum, mean, min, max, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions