Skip to content

API: consistently preserve null values for **0 in nullable dtypes #63094

@MarcoGorelli

Description

@MarcoGorelli
In [35]: pd.Series([1, pd.NA], dtype='Int64') ** 0
Out[35]:
0    1
1    1
dtype: Int64

In [36]: pd.Series([1, pd.NA], dtype='Int64[pyarrow]') ** 0
Out[36]:
0       1
1    <NA>
dtype: int64[pyarrow]

The pandas nullable types return 1 for NA ** 0, whereas the pyarrow ones preserve NA

Following the general rule outlined in #62506 (comment) by @jorisvandenbossche

I think the general rule is that NA values always propagate in element-wise functions (certainly for a generic ufunc where we might not know what it is doing exactly, for the reason @twast outlined), except for a function that specifically checks for NA (isna/notna).

, and also for compatibility with other tools, I'd suggest that NA should be consistently preserved here


Might this be considered for a breaking change in 3.0? #57064

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateNA - MaskedArraysRelated to pd.NA and nullable extension arraysNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions