From e083962a05ab724b20c70365d6f081e468d8be32 Mon Sep 17 00:00:00 2001 From: Alex Lim Date: Mon, 10 Aug 2020 14:26:14 +0000 Subject: [PATCH] CLN: Masking array for nan check, changing array dtype (#35498) --- pandas/_libs/index.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/index.pyx b/pandas/_libs/index.pyx index b12c8830f15ab..0b11860848ac0 100644 --- a/pandas/_libs/index.pyx +++ b/pandas/_libs/index.pyx @@ -270,11 +270,11 @@ cdef class IndexEngine: Py_ssize_t i, j, n, n_t, n_alloc self._ensure_mapping_populated() - if isnaobj(targets).any(): + if targets[isnaobj(targets)].size > 0: new_targets = [0 if checknull(t) else t for t in targets] new_values = [0 if checknull(v) else v for v in self._get_index_values()] - targets = np.array(new_targets, dtype=object) - values = np.array(new_values, dtype=object) + targets = np.array(new_targets, dtype=targets.dtype) + values = np.array(new_values, dtype=self._get_index_values().dtype) else: values = np.array(self._get_index_values(), copy=False)