Skip to content

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

Closed
@tui-rob

Description

@tui-rob

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions