Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2473,7 +2473,7 @@ def _mode(self, dropna: bool = True) -> Categorical:
mask = self.isna()

res_codes = algorithms.mode(codes, mask=mask)
res_codes = cast(np.ndarray, res_codes)
res_codes = cast("np.ndarray", res_codes)
assert res_codes.dtype == codes.dtype
res = self._from_backing_data(res_codes)
return res
Expand Down Expand Up @@ -2614,7 +2614,9 @@ def _categories_match_up_to_permutation(self, other: Categorical) -> bool:
-------
bool
"""
return hash(self.dtype) == hash(other.dtype)
# Optimized: call __eq__ directly, which avoids two hash computations and
# is a cheap equality test (faster than hashing for CategoricalDtype)
return self.dtype == other.dtype

def describe(self) -> DataFrame:
"""
Expand Down