Skip to content

ENH: Accept pd.NA as a float #56797

Closed
Closed
@mdruiter

Description

@mdruiter

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

In float[pyarrow] data, missings values are pd.NA. I can easily convert these frames to floats:

pd.Series([pd.NA], dtype='float[pyarrow]').astype('float')

0 NaN
dtype: float64

But in the pd.Series constructor, I cannot use pd.NAs:

pd.Series([pd.NA], dtype='float')

TypeError: float() argument must be a string or a real number, not 'NAType'

Is this by design?

Feature Description

It would be so much more convenient if pd.NA would 'just' be recognized as a np.nan in float context...

Alternative Solutions

Using .astype('float') is a workaround but makes code less generic.

Additional Context

I searched for issues like this or a design statement, but could not find anything about this specific thing, which surprised me as it feels like a common inconvenience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closing CandidateMay be closeable, needs more eyeballsEnhancementNeeds TriageIssue that has not been reviewed by a pandas team memberPDEP missing valuesIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions