-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
BUG: Fix TypeError in assert_index_equal when comparing CategoricalIndex with check_categorical=True and exact=False #61941
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
base: main
Are you sure you want to change the base?
Changes from 10 commits
085caa1
c0427e6
db54fad
5edf8ce
2b6d3a0
08739f2
ddf650e
3f998d4
4cc4e77
f9f62a3
5d5d668
459298d
ecaeb64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,3 +317,12 @@ def test_assert_multi_index_dtype_check_categorical(check_categorical): | |
tm.assert_index_equal(idx1, idx2, check_categorical=check_categorical) | ||
else: | ||
tm.assert_index_equal(idx1, idx2, check_categorical=check_categorical) | ||
|
||
|
||
def test_assert_index_equal_categorical_mismatch_categories(): | ||
# GH#61941 | ||
ci1 = CategoricalIndex(["a", "b", "c"], categories=["a", "b", "c"], ordered=False) | ||
ci2 = CategoricalIndex(["a", "x", "c"], categories=["a", "b", "c"], ordered=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you test when 1 index is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I had meant an additional test in addition to the one you had There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please , let me know if , I need to add an additional test . |
||
|
||
with pytest.raises(AssertionError, match="Index are different"): | ||
tm.assert_index_equal(ci1, ci2, check_exact=False, check_categorical=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use
isinstance
checks to call_internal_get_values
if the object is aCategoricalIndex
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thankyou ! for correcting me . I have updated that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one check fail due to:
CategoricalIndex does not have an _internal_get_values() method.
So should i use .value or something else . Please suggest