-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Allow keep="all" in duplicated method (#23251) #23252
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 all commits
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 |
---|---|---|
|
@@ -1252,6 +1252,9 @@ def drop_duplicates(self, keep='first', inplace=False): | |
if self.is_unique: | ||
return self._shallow_copy() | ||
|
||
if keep not in ['first', 'last', False]: | ||
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 saw your comment in the OP but having a hard time understanding here - what's the reason you need to add these checks and cannot include 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 part is breaking the symmetry between To differentiate, could raise a specific error relating to |
||
raise ValueError('keep must be either "first", "last" or False') | ||
|
||
duplicated = self.duplicated(keep=keep) | ||
result = self[np.logical_not(duplicated)] | ||
if inplace: | ||
|
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.
Can you change the RHS of this statement to be a set instead of a tuple? Also can you check if we are testing this raises somewhere already?