-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Index.drop raising Error when Index has duplicates #38070
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 8 commits
aa98b86
6316469
a5a28bc
965a7f0
237cdf3
8c9659d
caf05a7
066a948
c46fa3b
e7ea448
63de193
77392ed
f8b0b98
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 |
---|---|---|
|
@@ -1494,6 +1494,15 @@ def test_drop_tuple(self, values, to_drop): | |
with pytest.raises(KeyError, match=msg): | ||
removed.drop(drop_me) | ||
|
||
def test_drop_with_duplicates_in_index(self, index): | ||
# GH38051 | ||
if len(index) == 0: | ||
return | ||
expected = index.drop(index[0]).repeat(2) | ||
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. this works, but ideally we'd form
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. Had a similar idea, but the fixture contains indexes with duplicates. If drop is bad, we could use unique and index[1:] atfterwards? 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. can you write your idea out explicitly? im not clear on how it is different from what i wrote 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. Sorry, forget what I have said. I missed your first line |
||
index = index.repeat(2) | ||
result = index.drop(index[0]) | ||
tm.assert_index_equal(result, expected) | ||
|
||
@pytest.mark.parametrize( | ||
"attr", | ||
[ | ||
|
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.
could maybe use
@pytest.mark.filterwarnings
as a follow-up