Skip to content

Commit 90f2aa4

Browse files
author
tp
committed
improve test output for Categoricals
1 parent 15fa4bd commit 90f2aa4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

doc/source/whatsnew/v0.21.1.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ Categorical
117117
^^^^^^^^^^^
118118

119119
- Bug in :meth:`DataFrame.astype` where casting to 'category' on an empty ``DataFrame`` causes a segmentation fault (:issue:`18004`)
120-
-
120+
- Error messages in the testing module have been improved when items have
121+
different CategoricalDtype (:issue:`18069`)
121122
-
122123

123124
Other

pandas/util/testing.py

+4
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,12 @@ def assert_categorical_equal(left, right, check_dtype=True,
10741074
def raise_assert_detail(obj, message, left, right, diff=None):
10751075
if isinstance(left, np.ndarray):
10761076
left = pprint_thing(left)
1077+
elif pd.api.types.is_categorical_dtype(left):
1078+
left = repr(left)
10771079
if isinstance(right, np.ndarray):
10781080
right = pprint_thing(right)
1081+
elif pd.api.types.is_categorical_dtype(right):
1082+
right = repr(right)
10791083

10801084
msg = """{obj} are different
10811085

0 commit comments

Comments
 (0)