-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: add a keyword to the eq method to consider NAs equal #38063
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
Comments
@Karl-Wiese Given that you read the docs on nullable dtypes, and say yourself that "the second case is expected behaviour, too", I am not sure what actually expect / are looking for. When introducting the nullable dtypes, we considered which behaviour we wanted for equality of See also the docs at https://pandas.pydata.org/pandas-docs/stable/user_guide/missing_data.html#experimental-na-scalar-to-denote-missing-values (the docs about this are quite probably a bit scarce and scattered, that's something we need to improve) |
@jorisvandenbossche I expect that the behavior is consistent. Regardless if I use If others come across this "problem" you can use The original problem is that I want to compare two DataFrames cell by cell. And I want to accept that nan values are equal. This now needs the following: |
Well, that's inherently impossible, because we have chosen different behaviour for pd.NA compared to np.nan.
But to be clear, you already needed Note that the BTW, you might also be interested in the |
It was worth a try ;)
You are absolutely right! Thanks for your hints. For example, I apply a |
Code Sample
This works as expected. Comparing nan with nan evaluates to False.
However, this does not work as expected. Comparing nan with nan evaluates to nan.
Problem description
As in other programming languages I would expect the comparison between nan values for equality evaluates to False. In the first case, this works as expected. However, for the second it does not. I read the docs for the Nullable Boolean data type. It implements the Kleene Logic for Boolean data type. So, the second case is expected behavior, too. The issue is even explicitly stated in the docs. It is just not very consistent between the two cases.
I searched for similar bug reports and was not sure if they are directly related. For reference please look here:
Expected behavior
I would expect that the two cases behave consistently. In which way, is not so important for me.
Output of pd.show_versions()
Details
The text was updated successfully, but these errors were encountered: