Skip to content

.isin implicitly converts data types #19356

Closed
@caerner

Description

@caerner

Code Sample, a copy-pastable example if possible

import pandas as pd
pd.__version__
Out[1]: '0.22.0'

data = pd.Series([-9.0, 0.0])
data.isin([-9, -0.5])

Out[2]: 
0     True
1    False
dtype: bool

data = pd.Series([-9, 0])
data.isin([-9, -0.5])

Out[3]: 
0    True
1    True
dtype: bool

Problem description

.isin seems to implicitly convert the data type of what is passed in values depending on the data type of the Series. In the above example, I would expect the output to be (True, False) in both cases. There seems to have been a change in behavior after pandas version 0.19.2. With version 0.19.2 the output is in both cases (True, False).

Expected Output

import pandas as pd
pd.__version__
Out[1]: '0.19.2'

data = pd.Series([-9.0, 0.0])
data.isin([-9, -0.5])

Out[2]: 
0     True
1    False
dtype: bool

data = pd.Series([-9, 0])
data.isin([-9, -0.5])

Out[3]: 
0    True
1    False
dtype: bool

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselvesisinisin method

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions