Skip to content

Commit fe1926a

Browse files
committed
PERF: scalar not found in categorical's categories
1 parent 70b6552 commit fe1926a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ Performance improvements
343343
- Performance improvement in :meth:`DataFrame.replace` when provided a list of values to replace (:issue:`28099`)
344344
- Performance improvement in :meth:`DataFrame.select_dtypes` by using vectorization instead of iterating over a loop (:issue:`28317`)
345345
- Performance improvement in :meth:`Categorical.searchsorted` and :meth:`CategoricalIndex.searchsorted` (:issue:`28795`)
346+
- Performance improvement when searching for a scalar in a :meth:`Categorical` and the scalar is not found in the categories (:issue:``)
346347
347348
.. _whatsnew_1000.bug_fixes:
348349

pandas/core/arrays/categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ def f(self, other):
133133
return ret
134134
else:
135135
if opname == "__eq__":
136-
return np.repeat(False, len(self))
136+
return np.zeros(len(self), dtype=bool)
137137
elif opname == "__ne__":
138-
return np.repeat(True, len(self))
138+
return np.ones(len(self), dtype=bool)
139139
else:
140140
msg = (
141141
"Cannot compare a Categorical for op {op} with a "

0 commit comments

Comments
 (0)