Skip to content

Commit 0697610

Browse files
committed
simplify the fix, add issue reference number to corresponding test and tighten the wording in doc whatsnew
1 parent a581a74 commit 0697610

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pandas/core/categorical.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -2032,13 +2032,16 @@ def is_dtype_equal(self, other):
20322032
from pandas.core.series import Series
20332033

20342034
if isinstance(other, Series):
2035-
other_categorical = other.values
2036-
else:
2037-
other_categorical = other
2035+
other = Categorical(other)
20382036

2037+
<<<<<<< a581a743fe6740011e4fb0a7031ee92ce57b480b
20392038
return (self.categories.equals(other_categorical.categories) and
20402039
self.ordered == other_categorical.ordered)
20412040
>>>>>>> BUG: Fix Categorical comparsion with Series of dtype 'category'
2041+
=======
2042+
return (self.categories.equals(other.categories) and
2043+
self.ordered == other.ordered)
2044+
>>>>>>> simplify the fix, add issue reference number to corresponding test and tighten the wording in doc whatsnew
20422045
except (AttributeError, TypeError):
20432046
return False
20442047

pandas/tests/test_categorical.py

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def test_is_equal_dtype(self):
202202
CategoricalIndex(c1, categories=list('cab'))))
203203
assert not c1.is_dtype_equal(CategoricalIndex(c1, ordered=True))
204204

205+
# GH 16659
205206
s1 = pd.Series(c1)
206207
assert c1.is_dtype_equal(s1)
207208
assert not c2.is_dtype_equal(s1)

0 commit comments

Comments
 (0)