-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Bug in DataFrame.drop_duplicates for empty DataFrame throws error #22394
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 5 commits
03af0c1
79ee155
31f6099
6eb53f6
de745bb
3a5d97d
1f58a85
4f299c5
cab0958
68d69db
fb8845d
1f12545
20c03ef
fc61899
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 |
---|---|---|
|
@@ -263,6 +263,30 @@ def test_drop_duplicates_tuple(): | |
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_drop_duplicates_empty(): | ||
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 parameterize this on columns with 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. actually also need a test with no columns but an index e.g. so don't need to parameterize but test all of these cases (where the result is the input) |
||
# GH 20516 | ||
expected = DataFrame() | ||
result = expected.drop_duplicates() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
expected = DataFrame(columns=[]) | ||
result = expected.drop_duplicates() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
df = DataFrame(columns=['A', 'B', 'C']) | ||
result = df.drop_duplicates() | ||
expected = DataFrame(columns=[]) # The column infos are not carrying over | ||
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. I don't find this comment useful, rather put a comment about testing with empty columns, and below about an empty index |
||
tm.assert_frame_equal(result, expected) | ||
|
||
expected = DataFrame(index=[]) | ||
result = expected.drop_duplicates() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
expected = DataFrame(index=['A', 'B', 'C']) | ||
result = expected.drop_duplicates() | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_drop_duplicates_NA(): | ||
# none | ||
df = DataFrame({'A': [None, None, 'foo', 'bar', | ||
|
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.
raises an error