Skip to content

Commit 2771e57

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

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
@@ -2135,13 +2135,16 @@ def is_dtype_equal(self, other):
21352135
from pandas.core.series import Series
21362136

21372137
if isinstance(other, Series):
2138-
other_categorical = other.values
2139-
else:
2140-
other_categorical = other
2138+
other = Categorical(other)
21412139

2140+
<<<<<<< a581a743fe6740011e4fb0a7031ee92ce57b480b
21422141
return (self.categories.equals(other_categorical.categories) and
21432142
self.ordered == other_categorical.ordered)
21442143
>>>>>>> BUG: Fix Categorical comparsion with Series of dtype 'category'
2144+
=======
2145+
return (self.categories.equals(other.categories) and
2146+
self.ordered == other.ordered)
2147+
>>>>>>> simplify the fix, add issue reference number to corresponding test and tighten the wording in doc whatsnew
21452148
except (AttributeError, TypeError):
21462149
return False
21472150

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)