Skip to content

BUG: Index.equals different behavior for EA vs non-EA types #46164

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
3 tasks done
lukemanley opened this issue Feb 27, 2022 · 3 comments
Closed
3 tasks done

BUG: Index.equals different behavior for EA vs non-EA types #46164

lukemanley opened this issue Feb 27, 2022 · 3 comments
Labels
Bug Duplicate Report Duplicate issue or pull request ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses

Comments

@lukemanley
Copy link
Member

lukemanley commented Feb 27, 2022

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

f32 = pd.Index([1,2,3], dtype='float32')
f64 = pd.Index([1,2,3], dtype='float64')
F32 = pd.Index([1,2,3], dtype='Float32')
F64 = pd.Index([1,2,3], dtype='Float64')

>>> f32.equals(f64)
True

>>> F32.equals(F64)
False

Issue Description

The docs for Index.equals state that the dtype is not part of the equality test between indexes. The last example in the docs shows indexes with different dtypes being considered equal.

https://pandas.pydata.org/docs/reference/api/pandas.Index.equals.html

However, in the case of EA types the behavior is different and dtype does seem to be part of the equality check.

Expected Behavior

I'm not sure whether the different behavior between EA and non-EA types is actually a bug. Maybe it is expected in which case it should be mentioned in the docs?

Installed Versions

INSTALLED VERSIONS

commit : 90d32204ced71ea9f93fee3e271a6081d25a73c8
python : 3.8.12.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.16.3-microsoft-standard-WSL2
Version : #1 SMP Fri Apr 2 22:23:49 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.5.0.dev0+449.g90d32204ce
numpy : 1.21.5
pytz : 2021.3
dateutil : 2.8.2
pip : 21.3.1
setuptools : 60.5.0
Cython : 0.29.26
pytest : 6.2.5
hypothesis : 6.36.0
sphinx : 4.4.0
blosc : None
feather : None
xlsxwriter : 3.0.2
lxml.etree : 4.7.1
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.0.1
pandas_datareader: None
bs4 : 4.10.0
bottleneck : 1.3.2
fastparquet : 0.7.2
fsspec : 2021.11.0
gcsfs : 2021.11.0
markupsafe : 2.0.1
matplotlib : 3.5.1
numba : 0.55.0
numexpr : 2.8.0
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : 6.0.1
pyreadstat : 1.1.4
pyxlsb : None
s3fs : 2021.11.0
scipy : 1.7.3
sqlalchemy : 1.4.31
tables : 3.6.1
tabulate : 0.8.9
xarray : 0.18.2
xlrd : 2.0.1
xlwt : 1.3.0
zstandard : None

@lukemanley lukemanley added Bug Needs Triage Issue that has not been reviewed by a pandas team member ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses labels Feb 27, 2022
@phofl
Copy link
Member

phofl commented Mar 10, 2022

This does look intentional (in ExtensionArray.equals) and is documented as well in the ea method.

https://pandas.pydata.org/docs/reference/api/pandas.api.extensions.ExtensionArray.equals.html

But not sure if this should leak to Index.equals

cc @jbrockmendel

@jbrockmendel
Copy link
Member

unclear xref #33940

@mroeschke mroeschke added Needs Discussion Requires discussion from core team before further action and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 16, 2022
@phofl
Copy link
Member

phofl commented Jun 17, 2022

Closing in favor of #33940

@phofl phofl closed this as completed Jun 17, 2022
@phofl phofl added Duplicate Report Duplicate issue or pull request and removed Needs Discussion Requires discussion from core team before further action labels Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses
Projects
None yet
Development

No branches or pull requests

4 participants