Skip to content

Commit 174c51e

Browse files
committed
Address review comments
1 parent 01ade5a commit 174c51e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

doc/source/whatsnew/v0.23.0.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,8 @@ Indexing
12591259
- Bug in performing in-place operations on a ``DataFrame`` with a duplicate ``Index`` (:issue:`17105`)
12601260
- 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`)
12611261
- Bug in ``.loc`` with a ``uint64`` indexer (:issue:`20722`)
1262-
- Bug in ``CategoricalIndex.searchsorted`` where the method didn't return a scalar when the input values was scalar (:issue:`21019`)
1263-
- Bug in ``CategoricalIndex`` where slicing beyond the range of the data raised a KeyError (:issue:`21019`)
1262+
- Bug in :func:`CategoricalIndex.searchsorted` where the method did not return a scalar when the input values was scalar (:issue:`21019`)
1263+
- Bug in :class:`CategoricalIndex` where slicing beyond the range of the data raised a KeyError (:issue:`21019`)
12641264

12651265

12661266
MultiIndex

pandas/core/indexes/category.py

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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)