Skip to content

Commit 1e31fc3

Browse files
first try to implement alternative for where
1 parent 91802fb commit 1e31fc3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

pandas/core/indexes/category.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,7 @@ def where(self, cond, other=None):
507507
# 3. Rebuild CategoricalIndex.
508508
if other is None:
509509
other = self._na_value
510-
values = np.where(cond, self.values, other)
511-
cat = Categorical(values, dtype=self.dtype)
510+
cat = CategoricalIndex(self.values.where(cond, other), dtype=self.dtype)
512511
return self._shallow_copy(cat, **self._get_attributes_dict())
513512

514513
def reindex(self, target, method=None, level=None, limit=None,

0 commit comments

Comments
 (0)