Minor corrections to previous submit (#16820) · rs2/pandas@69454ec (original) (raw)

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ Bug Fixes
42 42 - 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`)
43 43 - Fixed a bug in failing to compute rolling computations of a column-MultiIndexed ``DataFrame`` (:issue:`16789`, :issue:`16825`)
44 44 - 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`)
46 46
47 47
48 48 Conversion
Original file line number Diff line number Diff line change
@@ -420,7 +420,7 @@ def reindex(self, target, method=None, level=None, limit=None,
420 420
421 421 indexer, missing = self.get_indexer_non_unique(np.array(target))
422 422
423 -if len(self.codes):
423 +if len(indexer):
424 424 new_target = self.take(indexer)
425 425 else:
426 426 new_target = target
@@ -434,8 +434,6 @@ def reindex(self, target, method=None, level=None, limit=None,
434 434 result = Index(np.array(self), name=self.name)
435 435 new_target, indexer, _ = result._reindex_non_unique(
436 436 np.array(target))
437 -# see GH 16819, indexer needs to be converted to correct type
438 -indexer = np.array(indexer, dtype=np.int64)
439 437 else:
440 438
441 439 codes = new_target.codes.copy()
Original file line number Diff line number Diff line change
@@ -425,7 +425,7 @@ def test_reindex_empty_index(self):
425 425 res, indexer = c.reindex(['a', 'b'])
426 426 tm.assert_index_equal(res, Index(['a', 'b']), exact=True)
427 427 tm.assert_numpy_array_equal(indexer,
428 -np.array([-1, -1], dtype=np.int64))
428 +np.array([-1, -1], dtype=np.intp))
429 429
430 430 def test_duplicates(self):
431 431