Skip to content

ENH: add method='dense' to rank #6343

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

Closed
wants to merge 2 commits into from
Closed

ENH: add method='dense' to rank #6343

wants to merge 2 commits into from

Conversation

dsm054
Copy link
Contributor

@dsm054 dsm054 commented Feb 13, 2014

This adds a method='dense' option to rank which does the same thing as the one in scipy.stats.rankdata: the first ranked group gets 1, the second 2, etc. Basically it ports the approach used in scipy.stats._rankdata_fused to the pandas rankdata implementation.

It also adds a few tests that the various methods do what they're supposed to, which I couldn't find a test for before.

closes #6333

@jreback jreback added this to the 0.14.0 milestone Feb 13, 2014
@dsm054
Copy link
Contributor Author

dsm054 commented Feb 13, 2014

(1) The tests I couldn't find were lurking in test_stats.py, so I should add to those instead of tossing them in test_series.py.

(2) I'm not sure what I'm doing which is breaking everything -- the code passes every test for me. Any obvious goofs I'm missing?

@jreback
Copy link
Contributor

jreback commented Feb 13, 2014

nothing obvious....

@dsm054
Copy link
Contributor Author

dsm054 commented Feb 14, 2014

Ah, got it. When I added total_tie_count, what was formerly dups=0 became dups, total_tie_count=0 and dups was no longer being initialized. That explains why even the cases which shouldn't have been affected at all started breaking, and why my tests passed even though Travis was barfing.

It must have worked for me by fluke. Will fix.

@dsm054 dsm054 closed this Feb 14, 2014
@dsm054 dsm054 deleted the add_dense_rank branch February 14, 2014 06:37
@dsm054
Copy link
Contributor Author

dsm054 commented Feb 14, 2014

Managed to get it working last night but got the branch into a weird inconsistent state. Will make a new one instead.

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 Enhancement Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: add 'dense' ranking method
2 participants