Skip to content

False negative on .equals() if indexes not identically ordered #13708

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

Closed
tui-rob opened this issue Jul 19, 2016 · 4 comments
Closed

False negative on .equals() if indexes not identically ordered #13708

tui-rob opened this issue Jul 19, 2016 · 4 comments

Comments

@tui-rob
Copy link
Contributor

tui-rob commented Jul 19, 2016

Hi,

I believe .equals() is incorrectly returning False on dataframes that are identical except for ordering of indexes. Think this may relate to closed issues #9330 and #9745.

Example

In [1]: import pandas as pd
In [2]: df1 = pd.DataFrame({'a':[1,2,3]}, index=['x','y','z'])
In [3]: df2 = pd.DataFrame({'a':[1,3,2]}, index=['x','z','y'])
In [4]: df1.equals(df2)
Out[4]: False #expected True
In [5]: df1.equals(df2.sort_index())
Out[5]: True 

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: x86
processor: x86 Family 6 Model 42 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.0
nose: 1.3.7
pip: 7.1.2
setuptools: 18.5
Cython: 0.23.4
numpy: 1.10.1
scipy: 0.16.0
statsmodels: 0.6.1
xarray: None
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5
matplotlib: 1.5.0
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.4.4
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: 1.0.9
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.38.0
@jreback
Copy link
Contributor

jreback commented Jul 19, 2016

these are by-definition not equal. Its quite strict.

@tui-rob
Copy link
Contributor Author

tui-rob commented Jul 19, 2016

Thanks @jreback. The docs for .equals() only refer to testing if two NDFrame objects contain the same elements (and don't mention index ordering). Would a pull request expanding on the doc string for this be likely to be accepted?

@jreback
Copy link
Contributor

jreback commented Jul 19, 2016

sure that would be fine

@wiso
Copy link

wiso commented Nov 20, 2018

I still see the docs saying: "Determines if two Index objects contain the same elements." without a reference to the check of the ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants