Skip to content

Add a method to ExtensionArray interface for whether an array contains NAs #22680

Closed
@TomAugspurger

Description

@TomAugspurger

In lots of places, pandas does something like if np.any(arr.isna()), which is wasteful as we have to create an ndarray of booleans just to check whether there are any True values.

Some arrays, like Arrow, know ahead of time whether there are any NAs in the array. Would it make sense to expose an API for an array saying whether they have any missing values?

With indexes, we work around this by caching a _hasnans value. That wouldn't work for mutable arrays.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementExtensionArrayExtending pandas with custom dtypes or arrays.PerformanceMemory or execution speed performance

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions