-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: pd.unique(Index) now returns Index as Index.unique #57679
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 7 commits
c22db31
d6c7a29
61cfc06
0864bd4
3f10b2b
05730bc
55e3744
3c3bfda
3eed933
016b45b
a550825
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 | ||
---|---|---|---|---|
|
@@ -570,6 +570,13 @@ def test_object_refcount_bug(self): | |||
for i in range(1000): | ||||
len(algos.unique(lst)) | ||||
|
||||
def test_index_returned(self, index): | ||||
# GH#57043 | ||||
index = index.repeat(2) | ||||
result = algos.unique(index) | ||||
expected = index.unique() | ||||
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. Is it doable to specify 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 think we can adapt the test from pandas/pandas/tests/base/test_unique.py Line 12 in 4692686
|
||||
tm.assert_index_equal(result, expected, exact=True) | ||||
|
||||
def test_on_index_object(self): | ||||
mindex = MultiIndex.from_arrays( | ||||
[np.arange(5).repeat(5), np.tile(np.arange(5), 5)] | ||||
|
@@ -579,7 +586,7 @@ def test_on_index_object(self): | |||
|
||||
mindex = mindex.repeat(2) | ||||
|
||||
result = pd.unique(mindex) | ||||
result = pd.unique(mindex).values | ||||
yuanx749 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
result.sort() | ||||
|
||||
tm.assert_almost_equal(result, expected) | ||||
|
@@ -639,7 +646,7 @@ def test_datetime64_dtype_array_returned(self): | |||
] | ||||
) | ||||
result = algos.unique(dt_index) | ||||
tm.assert_numpy_array_equal(result, expected) | ||||
tm.assert_index_equal(result, to_datetime(expected)) | ||||
rhshadrach marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
assert result.dtype == expected.dtype | ||||
|
||||
s = Series(dt_index) | ||||
|
@@ -670,7 +677,7 @@ def test_timedelta64_dtype_array_returned(self): | |||
|
||||
td_index = to_timedelta([31200, 45678, 31200, 10000, 45678]) | ||||
result = algos.unique(td_index) | ||||
tm.assert_numpy_array_equal(result, expected) | ||||
tm.assert_index_equal(result, to_timedelta(expected)) | ||||
rhshadrach marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
assert result.dtype == expected.dtype | ||||
|
||||
s = Series(td_index) | ||||
|
Uh oh!
There was an error while loading. Please reload this page.