Skip to content

Commit f8cfa01

Browse files
committed
Minor corrections to previous submit (pandas-dev#16820)
1 parent df5bfcf commit f8cfa01

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

doc/source/whatsnew/v0.20.3.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Performance Improvements
3737
Bug Fixes
3838
~~~~~~~~~
3939
- Fixed issue with dataframe scatter plot for categorical data that reports incorrect column key not found when categorical data is used for plotting (:issue:`16199`)
40-
- Handle reindexing an empty categorical index rather than throwing (:issue:`16770`)
40+
- Bug in reindexing on an empty CategoricalIndex (:issue:`16770`)
4141

4242

4343

pandas/core/indexes/category.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def reindex(self, target, method=None, level=None, limit=None,
420420

421421
indexer, missing = self.get_indexer_non_unique(np.array(target))
422422

423-
if len(self.codes):
423+
if len(indexer):
424424
new_target = self.take(indexer)
425425
else:
426426
new_target = target
@@ -434,8 +434,6 @@ def reindex(self, target, method=None, level=None, limit=None,
434434
result = Index(np.array(self), name=self.name)
435435
new_target, indexer, _ = result._reindex_non_unique(
436436
np.array(target))
437-
# see GH 16819, indexer needs to be converted to correct type
438-
indexer = np.array(indexer, dtype=np.int64)
439437
else:
440438

441439
codes = new_target.codes.copy()

pandas/tests/indexes/test_category.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def test_reindex_empty_index(self):
426426
res, indexer = c.reindex(['a', 'b'])
427427
tm.assert_index_equal(res, Index(['a', 'b']), exact=True)
428428
tm.assert_numpy_array_equal(indexer,
429-
np.array([-1, -1], dtype=np.int64))
429+
np.array([-1, -1], dtype=np.intp))
430430

431431
def test_duplicates(self):
432432

0 commit comments

Comments
 (0)