-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: ExtensionArray.unique #19869
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: ExtensionArray.unique #19869
Changes from all commits
7267544
07148db
c8b5852
5099573
a5d6b67
011d02e
b8711d3
c15d42d
a260d35
51f8a27
fc04612
41dd128
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 |
---|---|---|
|
@@ -88,6 +88,13 @@ def take(self, indexer, allow_fill=True, fill_value=None): | |
def copy(self, deep=False): | ||
return type(self)(self.data[:]) | ||
|
||
def unique(self): | ||
# Parent method doesn't work since np.array will try to infer | ||
# a 2-dim object. | ||
return type(self)([ | ||
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. use 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. would change this too 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. see above comment, define _consturct_from_sequence |
||
dict(x) for x in list(set(tuple(d.items()) for d in self.data)) | ||
]) | ||
|
||
@property | ||
def _na_value(self): | ||
return {} | ||
|
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.
future PR should prob add some examples here :> (and other doc-strings).
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.
True :) The only problem is that for ExtensionArray we don't have a direct working example, as you first need to subclass it (unless we use one of the existing ones like Categorical, but that also seems a bit strange)