Skip to content

Commit 6a85d27

Browse files
committed
Address review comments
1 parent 5f9692f commit 6a85d27

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

doc/source/whatsnew/v0.23.0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1289,8 +1289,8 @@ Indexing
12891289
- Bug in performing in-place operations on a ``DataFrame`` with a duplicate ``Index`` (:issue:`17105`)
12901290
- Bug in :meth:`IntervalIndex.get_loc` and :meth:`IntervalIndex.get_indexer` when used with an :class:`IntervalIndex` containing a single interval (:issue:`17284`, :issue:`20921`)
12911291
- Bug in ``.loc`` with a ``uint64`` indexer (:issue:`20722`)
1292-
- Bug in ``CategoricalIndex.searchsorted`` where the method didn't return a scalar when the input values was scalar (:issue:`21019`)
1293-
- Bug in ``CategoricalIndex`` where slicing beyond the range of the data raised a KeyError (:issue:`21019`)
1292+
- Bug in :func:`CategoricalIndex.searchsorted` where the method did not return a scalar when the input values was scalar (:issue:`21019`)
1293+
- Bug in :class:`CategoricalIndex` where slicing beyond the range of the data raised a KeyError (:issue:`21019`)
12941294

12951295

12961296
MultiIndex

pandas/core/indexes/category.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@ def get_loc(self, key, method=None):
436436
>>> non_monotonic_index.get_loc('b')
437437
array([False, True, False, True], dtype=bool)
438438
"""
439-
try:
440-
codes = self.categories.get_loc(key)
441-
except KeyError:
442-
raise KeyError("Category `{}` unknown".format(key))
439+
codes = self.categories.get_loc(key)
440+
if (codes == -1):
441+
raise KeyError(key)
442+
443443
return self._engine.get_loc(codes)
444444

445445
def get_value(self, series, key):

pandas/tests/categorical/test_analytics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_searchsorted(self):
8686
# Searching for single item argument, side='left' (default)
8787
res_cat = c1.searchsorted('apple')
8888
res_ser = s1.searchsorted('apple')
89-
exp = np.int64(2)
89+
exp = np.intp(2)
9090
assert res_cat == exp
9191
assert res_ser == exp
9292

0 commit comments

Comments
 (0)