-
Notifications
You must be signed in to change notification settings - Fork 358
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
Add Index unique #912
Add Index unique #912
Changes from all commits
cdd47a5
e280ae3
6eaffb8
72ca8e9
2ffb74f
037379b
be58f57
bb9b723
3047c9a
049748e
51dfb7e
17c709e
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 |
---|---|---|
|
@@ -140,6 +140,21 @@ def test_multi_index_names(self): | |
with self.assertRaises(PandasNotImplementedError): | ||
kidx.name = 'renamed' | ||
|
||
def test_index_unique(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. Sorry if I missed but did we have a test case for multi-index? 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. no, i think their implementation is slightly different, and i thought the scope of this PR is for Index, not MultiIndex (I was supposed to do in a separate PR). But do you prefer to have this 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. Ah, it's fine to target to implement it only in 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 added a |
||
kidx = self.kdf.index | ||
|
||
# here the output is different than pandas in terms of order | ||
expected = pd.Int64Index([0, 6, 9, 5, 1, 3, 8], dtype='int64') | ||
|
||
self.assert_eq(expected, kidx.unique()) | ||
self.assert_eq(expected, kidx.unique(level=0)) | ||
|
||
with self.assertRaisesRegexp(IndexError, "Too many levels*"): | ||
kidx.unique(level=1) | ||
|
||
with self.assertRaisesRegexp(KeyError, "Requested level (hi)*"): | ||
kidx.unique(level='hi') | ||
|
||
def test_multi_index_copy(self): | ||
arrays = [[1, 1, 2, 2], ['red', 'blue', 'red', 'blue']] | ||
idx = pd.MultiIndex.from_arrays(arrays, names=('number', 'color')) | ||
|
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.
@charlesdong1991, sorry can you remove
unique
at_MissingPandasLikeMultiIndex
as well?Techinically
MultiIndex
has the method calledunique
. It's a bit complicated becauseMultiIndex
inheritsIndex
, so I suggested to throw an exception :-)..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.
ok, removed! @HyukjinKwon
i will get some free time recently, and see if I could add some properties and functions for
Index
andMultiIndex
and then implementunique
forMultiIndex
if itholic hasn't implemented them all beforehand xD 😝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.
That would be awesome!!