Closed
Description
Examples
Example 1:
import pandas.core.algorithms as algos
comps = ['ss', 42]
values = ['42']
algos.isin(comps, values)
results in array([False, True], dtype=bool)
Example 2:
import pandas.core.algorithms as algos
comps = ['ss', np.nan]
values = [np.nan]
algos.isin(comps, values)
results in array([False, False], dtype=bool)
Expected Output
The results should be [False, False]
for example 1 and [False, True]
for example 2.
Problem description
The problem can be tracked down to this line: https://github.com/pandas-dev/pandas/blob/master/pandas/core/algorithms.py#L137
# we have failed, return object
values = np.asarray(values)
return ensure_object(values), 'object', 'object'
np.asarray(values)
tries to do smart things (like converting 42 to a string), it should be probably avoided by passing dtype=np.object
to it.
Output of pd.show_versions()
pandas 0.22.0