BUG: .equals method returns true when comparing floats with dtype object to None #44190
Closed
3 tasks done
Labels
Milestone
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
Issue Description
If one constructs a Series
left
containing floating-point data, but declared as dtypeobject
, and another Seriesright
of the same length, containing onlyNone
, thenleft.equals.right
returnsTrue
, even though the two series are demonstrably not equal.Making the comparison the other way round (i.e.
right.equals(right)
) returnsFalse
as is semantically correct.Some preliminary testing brings up the following conditions for the bug to occur:
left
can consist of any combination of float values - including+/-inf
,NaN
, and both integral and fractional floatsleft
contains values of any other type, the.equals
call will correctly returnFalse
- this includes ints andNone
itself.to_frame()
on both sides before calling.equals()
has the same results.Expected Behavior
left.equals(right)
should returnFalse
.Installed Versions
INSTALLED VERSIONS
commit : 945c9ed
python : 3.9.7.final.0
python-bits : 64
OS : Linux
OS-release : 4.4.0-19041-Microsoft
Version : #1237-Microsoft Sat Sep 11 14:32:00 PST 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.3.4
numpy : 1.21.3
pytz : 2021.3
dateutil : 2.8.2
pip : 20.3.4
setuptools : 58.2.0
Cython : 0.29.24
pytest : 6.2.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.2
IPython : 7.28.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.4.3
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 5.0.0
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : 1.3.24
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: