-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
BugTestingpandas testing functions or related to the test suitepandas testing functions or related to the test suite
Description
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
In [1]: import pandas as pd
In [2]: p_left = pd.Index([1, 2, 3], name="a", dtype="category")
In [3]: p_right = pd.Index([1, 2, 6], name="a", dtype="category")
In [4]: pd.testing.assert_index_equal(p_left, p_right, check_categorical=True, exact=False)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[10], line 1
----> 1 pd.testing.assert_index_equal(p_left, p_right, check_categorical=True, exact=False)
[... skipping hidden 1 frame]
File ~/pandas/core/ops/common.py:70, in _unpack_zerodim_and_defer.<locals>.new_method(self, other)
66 return NotImplemented
68 other = item_from_zerodim(other)
---> 70 return method(self, other)
File ~/pandas/core/arrays/categorical.py:143, in _cat_compare_op.<locals>.func(self, other)
141 msg = "Categoricals can only be compared if 'categories' are the same."
142 if not self._categories_match_up_to_permutation(other):
--> 143 raise TypeError(msg)
145 if not self.ordered and not self.categories.equals(other.categories):
146 # both unordered and different order
147 other_codes = recode_for_categories(
148 other.codes, other.categories, self.categories, copy=False
149 )
TypeError: Categoricals can only be compared if 'categories' are the same.
Issue Description
pandas asserters should always raise an AssertionError
.
Expected Behavior
I would expect this to raise an AssertionError
.
Installed Versions
Replace this line with the output of pd.show_versions()
Metadata
Metadata
Assignees
Labels
BugTestingpandas testing functions or related to the test suitepandas testing functions or related to the test suite