Skip to content

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

Merged
merged 6 commits into from
Jan 17, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

@phofl phofl Jan 9, 2021

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

Copy link
Contributor Author

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!


Before v1.2.0:

>>>import pandas as pd
pd.Series([0]).isin(['0'])
# 0 True
# dtype: bool
pd.Series([1]).isin(['1'])
# 0 True
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the hashes for?

Copy link
Contributor Author

@omarafifii omarafifii Jan 9, 2021

Choose a reason for hiding this comment

The 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.
Thanks for the feedback!!

# 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__(
Expand Down