-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Added docs for the change of behavior of isin #39064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
94095c7
7d36f0f
cd13e57
86f0e86
bc3a00c
22fe1ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4630,6 +4630,34 @@ def isin(self, values) -> "Series": | |
4 True | ||
5 False | ||
Name: animal, dtype: bool | ||
|
||
New behaviour from pandas v1.2.0 caused some tests to fail because users where unaware of this change. | ||
|
||
Before v1.2.0: | ||
|
||
>>>import pandas as pd | ||
pd.Series([0]).isin(['0']) | ||
# 0 True | ||
# dtype: bool | ||
pd.Series([1]).isin(['1']) | ||
# 0 True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah just show the new example (you can add a comment that strings and integers are distinct). Keep the style in-line with the other examples. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok thanks for the feedback, I will fix it. |
||
# dtype: bool | ||
pd.Series([1.1]).isin(['1.1']) | ||
# 0 True | ||
# dtype: bool | ||
|
||
From v1.2.0 | ||
|
||
>>>import pandas as pd | ||
pd.Series([0]).isin(['0']) | ||
# 0 False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the hashes for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was meant to be a comment, but you are right, it's better if I remove them. |
||
# dtype: bool | ||
pd.Series([1]).isin(['1']) | ||
# 0 False | ||
# dtype: bool | ||
pd.Series([1.1]).isin(['1.1']) | ||
# 0 False | ||
# dtype: bool | ||
""" | ||
result = algorithms.isin(self._values, values) | ||
return self._constructor(result, index=self.index).__finalize__( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we need an example from before 1.2 in the docstrings. Just a comment that we do no longer match strings containing numbers with integers and an example from the new behavior?
Also pls use versionchanged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was not sure if I should add the before part or not. Ok, I will remove it.
What do you mean by use versionchanged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. versionchanged:: 1.2.0
and comment after this (sphinx notation). You can look through the files for a complete example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for the help!