-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame.equals() wrongly returns True in case of identical blocks with different locations #28839
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
Yes, that's clearly a bug. Thanks for finding that! We seem to check the equality block by block. But that way we ignore the block locations .. (and thus how they map to column names) |
I am interested in working on this . |
@bhuvanakundumani Super, that would be very welcome! If you have any question or need a pointer, let me know. |
@jorisvandenbossche - I am reading more about BlockManger here : https://github.com/pydata/pandas-design/blob/master/source/internal-architecture.rst. |
@bhuvanakundumani that's a document describing a potential refactor of the internal BlockManager, so although it contains some description of the current sate, I think it is not the best document to read to understand the current implementation. I think in general we don't really have a good documentation of this, sorry .. The code where I would start looking is at pandas/pandas/core/internals/managers.py Lines 1398 to 1420 in 58d34d9
We might need an additional check that the block locations are also equal. |
@jorisvandenbossche thanks for the info. will look into it. |
Pushing off the 1.0 milestone. Would certainly take a PR for 1.0 if anyone is able to get to it in time. |
I will look into it |
…andas-dev#28839) The function was returning True in case shown in added test. The cause of the problem was sorting Blocks of DataFrame by type, and then mgr_locs before comparison. It resulted in arranging the identical blocks in the same way, which resulted in having the same two lists of blocks. Changing sorting order to (mgr_locs, type) resolves the problem, while not interrupting the other aspects of comparison.
…andas-dev#28839) The function was returning True in case shown in added test. The cause of the problem was sorting Blocks of DataFrame by type, and then mgr_locs before comparison. It resulted in arranging the identical blocks in the same way, which resulted in having the same two lists of blocks. Changing sorting order to (mgr_locs, type) resolves the problem, while not interrupting the other aspects of comparison.
Code Sample, a copy-pastable example if possible
Problem description
When I read the source code, I did a simple test on it, and then failed.
Expected Output
I expected it return False
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.6.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 0.25.0
numpy : 1.16.4
pytz : 2019.1
dateutil : 2.8.0
pip : 19.2.2
setuptools : 40.6.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.3.3
html5lib : None
pymysql : 0.9.3
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : 2.10.1
IPython : 7.5.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.3.3
matplotlib : 3.1.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : None
sqlalchemy : 1.3.4
tables : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
The text was updated successfully, but these errors were encountered: