Skip to content

Add test_masking_duplicate_columns #37125

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

Closed
wants to merge 5 commits into from
Closed
Changes from 2 commits
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
6 changes: 6 additions & 0 deletions pandas/tests/frame/test_nonunique_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,3 +513,9 @@ def test_set_value_by_index(self):

df.iloc[:, 0] = 3
tm.assert_series_equal(df.iloc[:, 1], expected)

Copy link
Contributor

Choose a reason for hiding this comment

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

can you construct this exactly as in the OP; e.g. we want these converted to numpy before the constructor. also pls parameterize as there are multiple tests indicated

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, I am not sure I follow, what would be a good way to parameterize in this scope?

I saw that in order functions we have access to a check function, but if I were to put my test inside another function, it would probably be the test_columns_with_dups function, which has no access to this particular mechanism.

As for the numpy parts, I just added a commit to address that, maybe it is as it should be, thanks for the review!

Copy link
Author

Choose a reason for hiding this comment

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

@jreback I think I misread your request the first time, you are saying there should be other cases for this test? Looking at the issue again it seems to me that this single test should be enough

def test_masking_duplicate_columns_mixed_dtypes(self):
# https://github.com/pandas-dev/pandas/issues/31954
df = pd.DataFrame([[0.0, 1], [2.0, 3]], columns=[0, 0])
expected = DataFrame([[np.nan, np.nan], [np.nan, 3.0]], columns=[0, 0])
tm.assert_frame_equal(df[df > 2], expected)