Skip to content

DOC: Undocumented change in .isin behavior from 1.1.5 to 1.2.0 #38781

Closed
@StefanBRas

Description

@StefanBRas

Location of the documentation

https://pandas.pydata.org/docs/whatsnew/v1.2.0.html

Documentation problem

There seems to be an undocumented change with how isin works.
pandas 1.1.5:

import pandas as pd
pd.Series([0]).isin(['0']) 
# 0    True
# dtype: bool
pd.Series([1]).isin(['1']) 
# 0    True
# dtype: bool
pd.Series([1.1]).isin(['1.1']) 
# 0    True
# dtype: bool

But in pandas 1.2.0 (and 1.2.0rc):

import pandas as pd
pd.Series([0]).isin(['0']) 
# 0    False
# dtype: bool
pd.Series([1]).isin(['1']) 
# 0    False
# dtype: bool
pd.Series([1.1]).isin(['1.1']) 
# 0    False
# dtype: bool

But the release notes mentions nothing about it.
I have not posted this issue as an bug, because I think the newer implementation is the better implementation.
However I propose adding the change to the release notes for other people like me where the change broke tests in a pipeline.

Suggested fix for documentation

Add a line mentioning that isin no longer returns true when comparing floats to a string of the float.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsDtype ConversionsUnexpected or buggy dtype conversionsTestingpandas testing functions or related to the test suitegood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions