Skip to content

TST: category isin on frame #34363

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 4 commits into from
Jul 10, 2020
Merged

TST: category isin on frame #34363

merged 4 commits into from
Jul 10, 2020

Conversation

vampypandya
Copy link
Contributor

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Thanks @vampypandya

Comment on lines 199 to 200
expected1 = DataFrame({"a": [True, True, True], "b": [False, False, False]})
expected2 = DataFrame({"a": [True, True, True], "b": [False, False, 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's the difference between these two? Can you just use one, call it expected, and use it for both assertions?

@jreback jreback added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Categorical Categorical Data Type labels May 25, 2020
@jreback jreback added this to the 1.1 milestone May 25, 2020
@jreback jreback changed the title Test Cases for #34256 TST: category isin on frame May 25, 2020
@vampypandya vampypandya requested a review from jreback May 25, 2020 19:54
"category",
[
pd.DataFrame({"a": [1, 2, 3]}, dtype="category"),
pd.Series([1, 2, 3]).astype("category"),
Copy link
Member

Choose a reason for hiding this comment

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

You can set this using dtype="category" instead of astyping

@@ -189,3 +189,18 @@ def test_isin_empty_datetimelike(self):
tm.assert_frame_equal(result, expected)
result = df1_td.isin(df3)
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize(
"category",
Copy link
Member

Choose a reason for hiding this comment

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

Rather than calling this argument "category" something like "values" or "other" (for example) seems more appropriate

)
def test_isin_category_frame(self, category):
# GH#34256
df = pd.DataFrame.from_dict({"a": [1, 2, 3], "b": [4, 5, 6]})
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 we need from_dict here

@TomAugspurger
Copy link
Contributor

@vampypandya can you update with the requested changes?

@jreback jreback merged commit 2c3edaa into pandas-dev:master Jul 10, 2020
@jreback
Copy link
Contributor

jreback commented Jul 10, 2020

thanks @vampypandya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Categorical Categorical Data Type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: DataFrame.isin fails when other is a categorical series
5 participants