Skip to content

Commit

Permalink
Minor corrections to previous submit (#16820)
Browse files Browse the repository at this point in the history
  • Loading branch information
ri938 committed Jul 7, 2017
1 parent 3092bbc commit 69454ec
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.20.3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Bug Fixes
- 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`)
- Fixed a bug in failing to compute rolling computations of a column-MultiIndexed ``DataFrame`` (:issue:`16789`, :issue:`16825`)
- Bug in a DataFrame/Series with a ``TimedeltaIndex`` when slice indexing (:issue:`16637`)
- Handle reindexing an empty categorical index rather than throwing (:issue:`16770`)
- Bug in reindexing on an empty ``CategoricalIndex`` (:issue:`16770`)


Conversion
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def reindex(self, target, method=None, level=None, limit=None,

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

if len(self.codes):
if len(indexer):
new_target = self.take(indexer)
else:
new_target = target
Expand All @@ -434,8 +434,6 @@ def reindex(self, target, method=None, level=None, limit=None,
result = Index(np.array(self), name=self.name)
new_target, indexer, _ = result._reindex_non_unique(
np.array(target))
# see GH 16819, indexer needs to be converted to correct type
indexer = np.array(indexer, dtype=np.int64)
else:

codes = new_target.codes.copy()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def test_reindex_empty_index(self):
res, indexer = c.reindex(['a', 'b'])
tm.assert_index_equal(res, Index(['a', 'b']), exact=True)
tm.assert_numpy_array_equal(indexer,
np.array([-1, -1], dtype=np.int64))
np.array([-1, -1], dtype=np.intp))

def test_duplicates(self):

Expand Down

0 comments on commit 69454ec

Please sign in to comment.