Description
- 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.
Code Sample, a copy-pastable example
import pandas as pd
pd.Index(['10607', '6574', '6621', '99917']).equals(pd.Index(['99917', '10607', '6574', '6621'])) # False
set(['10607', '6574', '6621', '99917']) == set(['99917', '10607', '6574', '6621']) # True
Problem description
I have seen #13708, but according to documentation:
Determine if two Index objects contain the same elements.
Should it return True
instead?
Reading how the function is implemented:
pandas/pandas/core/indexes/base.py
Lines 4072 to 4074 in 3adf334
It relies on:
pandas/pandas/core/dtypes/missing.py
Lines 421 to 431 in 3adf334
Which is indeed strict and do take order into account.
Expected Output
As I understand the equality of index is about having the same elements. It is not required the elements having the same order. I have the feeling that once pandas worked this way (maybe before v0.23
).
What is the intended way ? Maybe the documentation should be a bit more explicit about this comparison. If you indicate me where I can update the doc, I will be glad to edit it.
Output of pd.show_versions()
commit : None
python : 3.6.9.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-91-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.3
numpy : 1.18.2
pytz : 2019.3
dateutil : 2.8.1
pip : 9.0.1
setuptools : 46.1.3
Cython : 0.29.14
pytest : 5.3.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.1.8
lxml.etree : 4.3.4
html5lib : 0.999999999
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : 2.11.1
IPython : 7.13.0
pandas_datareader: None
bs4 : 4.7.1
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.3.4
matplotlib : 3.2.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.13.0
pytables : None
pytest : 5.3.2
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.15
tables : None
tabulate : 0.8.3
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.1.8
numba : None