-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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: series.eq(other) does not equal series == other when the series contain pd.NA #36941
Comments
You're using object dtype. Try with the nullable integer dtype: https://pandas.pydata.org/docs/user_guide/integer_na.html |
That doesn't change the fact that |
The documentation doesn't say that they're the same, and this is the behavior you'd get using np.nan as well. Maybe the docs could be updated to reflect that? |
Ideally you don't use object dtype, but I would say that it is still a bug, though. I suppose this comes from the following numpy behaviour:
We can't control numpy, but we should still ensure that this incorrect behaviour is not broadcasted to the resulting Series. |
Silly me, I was looking at the docstring for equals. Ignore everything I just said. |
The documentation has a note "Mismatched indices will be unioned together. NaN values are considered different (i.e. NaN != NaN)." So, I think this is intended. |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
From the documentation of
Series.eq
: "Equivalent toseries == other
", I would expectdf.a == df.b
to yield the same result asdf.a.eq(df.b)
, but it doesn't when the series containpd.NA
.Expected Output
df.a.eq(df.b)
gives the same result asdf.a == df.b
even when the series containpd.NA
.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : db08276
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-48-generic
Version : #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.3
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.1
setuptools : 49.2.1.post20200802
Cython : None
pytest : 6.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.3.1
lxml.etree : 4.5.1
html5lib : None
pymysql : 0.10.0
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.15.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 0.7.4
fastparquet : None
gcsfs : None
matplotlib : 3.3.0
numexpr : None
odfpy : None
openpyxl : 3.0.4
pandas_gbq : None
pyarrow : 1.0.0
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : 1.3.18
tables : None
tabulate : 0.8.7
xarray : 0.15.1
xlrd : 1.2.0
xlwt : None
numba : 0.48.0
The text was updated successfully, but these errors were encountered: