Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jorisvandenbossche opened this issue Nov 10, 2021 · 0 comments · Fixed by #44390
Closed

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

jorisvandenbossche opened this issue Nov 10, 2021 · 0 comments · Fixed by #44390
Labels
NA - MaskedArrays Related to pd.NA and nullable extension arrays
Milestone

Comments

@jorisvandenbossche
Copy link
Member

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).

@jorisvandenbossche jorisvandenbossche added the NA - MaskedArrays Related to pd.NA and nullable extension arrays label Nov 10, 2021
@jorisvandenbossche jorisvandenbossche added this to the Contributions Welcome milestone Nov 10, 2021
@jreback jreback modified the milestones: Contributions Welcome, 1.4 Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants