Skip to content

BUG: FloatingArray.equals should consider NaNs in same location as equal #44382

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

From #43930 (comment). Currently we have

In [24]: arr1 = pd.arrays.FloatingArray(np.array([1.0, np.nan, 2.0]), np.array([False, False, True]))

In [25]: arr1
Out[25]: 
<FloatingArray>
[1.0, nan, <NA>]
Length: 3, dtype: Float64

In [26]: arr2 = pd.arrays.FloatingArray(np.array([1.0, np.nan, 2.0]), np.array([False, False, True]))

In [27]: arr1.equals(arr2)
Out[27]: False

For nullable arrays, NAs in the same location are considered equal. For plain float arrays, we consider NaNs as equal. Although for FloatingArray we currently distinguish both NA and NaN, I think we should consider both as equal if in the same location, to preserve the goal of this function (NaN equal to NaN, and NA equal to NA, to be clear, not mixed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    NA - MaskedArraysRelated to pd.NA and nullable extension arrays

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions