-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
ENH: use stable sort in value_counts #63158
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: use stable sort in value_counts #63158
Conversation
rhshadrach
left a comment
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.
Change you Series.value_counts docstring too and add a test - something like
ser = pd.Series(np.random.randint(0, 100, 10000))
result = ser.value_counts()
expected = ser.value_counts(sort=False).sort_values(ascending=False, kind="stable")
tm.assert_series_equal(result, expected)seems to fairly reliably fail without this PR (100000 out of 100000 times). Should set the NumPy random seed in the test.
I don't think this is a breaking change since unstable sorting doesn't guarantee anything about the output order. Would also like another eye on this.
Thank you for the hint, dc431ca
Do I need to react somehow? |
bd222df to
bf361c7
Compare
bf361c7 to
908fd7e
Compare
rhshadrach
left a comment
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.
lgtm
|
Thanks @cmp0xff |
value_countsand record it in the docs #63155doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.AGENTS.md.