Skip to content

Commit 69454ec

Browse files
committed
Minor corrections to previous submit (#16820)
1 parent 3092bbc commit 69454ec

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
@@ -42,7 +42,7 @@ Bug Fixes
4242
- Fixed compat with loading a ``DataFrame`` with a ``PeriodIndex``, from a ``format='fixed'`` HDFStore, in Python 3, that was written in Python 2 (:issue:`16781`)
4343
- Fixed a bug in failing to compute rolling computations of a column-MultiIndexed ``DataFrame`` (:issue:`16789`, :issue:`16825`)
4444
- Bug in a DataFrame/Series with a ``TimedeltaIndex`` when slice indexing (:issue:`16637`)
45-
- Handle reindexing an empty categorical index rather than throwing (:issue:`16770`)
45+
- Bug in reindexing on an empty ``CategoricalIndex`` (:issue:`16770`)
4646

4747

4848
Conversion

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
@@ -425,7 +425,7 @@ def test_reindex_empty_index(self):
425425
res, indexer = c.reindex(['a', 'b'])
426426
tm.assert_index_equal(res, Index(['a', 'b']), exact=True)
427427
tm.assert_numpy_array_equal(indexer,
428-
np.array([-1, -1], dtype=np.int64))
428+
np.array([-1, -1], dtype=np.intp))
429429

430430
def test_duplicates(self):
431431

0 commit comments

Comments
 (0)