Skip to content

Commit

Permalink
CLN: differentiate 0 and np.nan (pandas-dev#35498)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhlim committed Aug 21, 2020
1 parent ca82d69 commit 4f9d9df
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,10 @@ cdef class IndexEngine:
self._ensure_mapping_populated()
values = np.array(self._get_index_values(), copy=False)
targets_mask = isnaobj(targets)
values_mask = isnaobj(values)
if targets_mask.any():
targets[targets_mask] = 0
values[isnaobj(values)] = 0
values[values_mask] = 0

stargets = set(targets)
n = len(values)
Expand Down Expand Up @@ -325,8 +326,13 @@ cdef class IndexEngine:
n_alloc += 10_000
result = np.resize(result, n_alloc)

result[count] = j
count += 1
if val == 0:
if targets_mask[i] == values_mask[j]:
result[count] = j
count += 1
else:
result[count] = j
count += 1

# value not found
else:
Expand Down

0 comments on commit 4f9d9df

Please sign in to comment.