-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
ENH: Add paramenter index
to drop_duplicates
to drop duplicate indices
#58648
Comments
Hi, I would like to work on this issue. I'll start implementing the feature and submit a PR soon. |
Thanks for the suggestion! I think this feature will be useful so I'm ok with it being added. If I understood you correctly, if someone passes |
This is how it can look like if an index parameter is added:
It turned out a bit more complex than I expected. A simpler alternative might be better to accept the index name in the subset parameter:
|
My current implementation is to drop indices only. However, my take on an alternative would be adding two parameters:
|
So if
I'm personally leaning towards option 2 which basically treats the index as a value of the row |
@Yousinator Not a fan of having 2 parameters, that will be confusing with the existing |
My final take would be having a If we where to go for the If going with the second option we could rearrange the indices at the end if duplicate indices exist with different values |
Same, I think this is what most people would expect. |
@bingbong-sempai @Aloqeely are you willing to reopen the issue and proceed forward, or shall we consider it closed? |
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
There currently is no elegant pattern to drop duplicate indices.
I think what people usually do is
df[~df.index.duplicated(keep='first')]
Feature Description
Add a new parameter to
drop_duplicates
to specify dropping duplicate indices.An option could be a
index=True
to do this, similar to when merging on an index.Alternative Solutions
Allow the
subset
parameter ofdrop_duplicates
to accept the name of the index.Additional Context
No response
The text was updated successfully, but these errors were encountered: