Skip to content

Commit 1857bff

Browse files
qwhelanjreback
authored andcommitted
PERF: restore performance for unsorted CategoricalDtype comparison (#27448)
1 parent f2886c1 commit 1857bff

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pandas/core/dtypes/dtypes.py

+6
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@ def __eq__(self, other: Any) -> bool:
406406
# but same order is not necessary. There is no distinction between
407407
# ordered=False and ordered=None: CDT(., False) and CDT(., None)
408408
# will be equal if they have the same categories.
409+
if (
410+
self.categories.dtype == other.categories.dtype
411+
and self.categories.equals(other.categories)
412+
):
413+
# Check and see if they happen to be identical categories
414+
return True
409415
return hash(self) == hash(other)
410416

411417
def __repr__(self):

0 commit comments

Comments
 (0)