Skip to content
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

BUG: pd.unique(Index) now returns Index as Index.unique #57679

Merged
merged 11 commits into from
Mar 12, 2024

Conversation

yuanx749
Copy link
Contributor

@yuanx749 yuanx749 commented Feb 29, 2024

Some old tests are adjusted for consistency.

@yuanx749 yuanx749 marked this pull request as ready for review February 29, 2024 16:12
@yuanx749
Copy link
Contributor Author

yuanx749 commented Mar 5, 2024

Looks like CI failures are not related. Could you please review this PR? @rhshadrach

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Some questions / requests.

pandas/core/algorithms.py Show resolved Hide resolved
# GH#57043
index = index.repeat(2)
result = algos.unique(index)
expected = index.unique()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it doable to specify expected explicitly here instead of using index.unique()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can adapt the test from

def test_unique(index_or_series_obj):

pandas/tests/test_algos.py Outdated Show resolved Hide resolved
pandas/tests/test_algos.py Outdated Show resolved Hide resolved
pandas/tests/test_algos.py Outdated Show resolved Hide resolved
@yuanx749
Copy link
Contributor Author

yuanx749 commented Mar 9, 2024

Thank you for the review. I push a new commit to address the requests. @rhshadrach

pandas/tests/test_algos.py Show resolved Hide resolved
pandas/tests/test_algos.py Outdated Show resolved Hide resolved
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, wouldn't mind another eye @mroeschke

@mroeschke mroeschke added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Index Related to the Index class or subclasses labels Mar 12, 2024
@mroeschke mroeschke added this to the 3.0 milestone Mar 12, 2024
@mroeschke mroeschke merged commit f15f678 into pandas-dev:main Mar 12, 2024
53 checks passed
@mroeschke
Copy link
Member

Thanks @yuanx749

@yuanx749 yuanx749 deleted the unique-index branch March 13, 2024 03:58
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…7679)

* Add test

* Fix

* Adjust tests

* Add whatsnew

* Improve tests

* Remove duplicate test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: pd.unique(index) does not always return an index
3 participants