Skip to content

BUG: Index.equals returns incorrect result #36065

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
2 of 3 tasks
YarShev opened this issue Sep 2, 2020 · 9 comments
Closed
2 of 3 tasks

BUG: Index.equals returns incorrect result #36065

YarShev opened this issue Sep 2, 2020 · 9 comments
Labels

Comments

@YarShev
Copy link
Contributor

YarShev commented Sep 2, 2020

  • 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.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

# Your code here
import pandas
i1 = pandas.date_range("2008-01-01", periods=1000, freq="12H")
i2 = pandas.date_range("2008-01-01", periods=1000, freq="12H")
i2.freq = None
i1.equals(i2)
True
# but freqs are now equal
i1.freq == i2.freq
False

Problem description

Could anyone please explain? Is it normal behavior for equals?

Output of pd.show_versions()

pandas : 1.1.1
numpy : 1.18.4
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.2
setuptools : 41.2.0
Cython : None
pytest : 5.4.2
hypothesis : None
sphinx : None
blosc : None
feather : 0.4.1
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.14.0
pandas_datareader: None
bs4 : 4.9.1
bottleneck : None
fsspec : 0.7.3
fastparquet : None
gcsfs : None
matplotlib : 3.2.1
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : 0.16.0
pytables : None
pyxlsb : None
s3fs : 0.4.2
scipy : 1.4.1
sqlalchemy : 1.3.17
tables : 3.6.1
tabulate : None
xarray : 0.15.1
xlrd : 1.2.0
xlwt : None
numba : None

@YarShev YarShev added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 2, 2020
@MarcoGorelli
Copy link
Member

MarcoGorelli commented Sep 2, 2020

but freqs are now equal

i1.equals(i2) only tells you whether they are equal, it doesn't set them to be equal. Closing then, but please let me know if I've misunderstood the report

@YarShev
Copy link
Contributor Author

YarShev commented Sep 2, 2020

@MarcoGorelli , yes, i1.equals(i2) has not to set them to be equal. However, since i1.freq and i2.freq are not equal, I guess that i1.equals(i2) has to return False in this case. Or I misunderstand this?

@MarcoGorelli MarcoGorelli reopened this Sep 2, 2020
@MarcoGorelli
Copy link
Member

Yes, sorry, you're right - thanks for explaining!

@MarcoGorelli
Copy link
Member

@YarShev though actually, the docs do say

The things that are being compared are:

The elements inside the Index object.

The order of the elements inside the Index object.

and give an example showing that other attributes such as dtype are not compared.

So, it seems correct?

@dsaxton
Copy link
Member

dsaxton commented Sep 2, 2020

xref #33940

@YarShev
Copy link
Contributor Author

YarShev commented Sep 2, 2020

@MarcoGorelli , yes the docs are saying exactly what you mentioned. However, may be it's worth doing this method more restricted?

@MarcoGorelli
Copy link
Member

@MarcoGorelli , yes the docs are saying exactly what you mentioned. However, may be it's worth doing this method more restricted?

Possibly, but it seems this is already being discussed in the issue linked to by Daniel.

If this isn't a bug then, is it OK to close it?

@YarShev
Copy link
Contributor Author

YarShev commented Sep 2, 2020

@MarcoGorelli , I think the issue can be closed if it is treated as a bug. Can we keep it as feature request or something like that?

@MarcoGorelli
Copy link
Member

@YarShev it looks like @attack68 has kindly mentioned this in the above issue, so I'll close this for now - thanks for your report!

@simonjayhawkins simonjayhawkins removed the Needs Triage Issue that has not been reviewed by a pandas team member label Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants