Skip to content

BUG: Let check_exact_index default to True for integers #58189

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

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

Aloqeely
Copy link
Member

@Aloqeely Aloqeely commented Apr 8, 2024

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review here.

  1. Could you add to the docstring exact parameter that this applies to the index in 3.0?
  2. Could you add a whatsnew note in v3.0.0.rst
  3. Could you add some tests?

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Apr 22, 2024
@Aloqeely
Copy link
Member Author

No problem at all. Not sure how many tests are needed but I think this should be sufficient

Comment on lines 930 to 931
all(is_numeric_dtype(dtype) for dtype in left_index_dtypes)
and not any(is_float_dtype(dtype) for dtype in left_index_dtypes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could check dtype.kind in "iu" to check integer types in one go

Copy link
Member Author

@Aloqeely Aloqeely Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant! That doesn't seem to work for multiindexes (as in I can't just use this on index.dtype) as the dtype is always object (why?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't seem to work for multiindexes

Probably because MultiIndex can be composed of levels that are mixed types so object is the safest type

@mroeschke mroeschke added this to the 3.0 milestone Apr 24, 2024
@mroeschke mroeschke merged commit b6c15ea into pandas-dev:main Apr 24, 2024
45 of 46 checks passed
@mroeschke
Copy link
Member

Thanks @Aloqeely

pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…8189)

* Default check_exact_index to True for integers

* Fix pyright issue

* fix logic for multiindex

* Pre-commit stuff

* Address review comments

---------

Co-authored-by: Abdulaziz Aloqeely <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: assert_index_equal defaults to check_exact_index=False on integers
2 participants