Skip to content

DOC: describe any expected ordering of value counts when sort=False #51420

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
1 task done
mvashishtha opened this issue Feb 15, 2023 · 3 comments · Fixed by #52857
Closed
1 task done

DOC: describe any expected ordering of value counts when sort=False #51420

mvashishtha opened this issue Feb 15, 2023 · 3 comments · Fixed by #52857
Assignees
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Docs

Comments

@mvashishtha
Copy link

mvashishtha commented Feb 15, 2023

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

Documentation problem

The documentation says nothing about what value_counts() for series or dataframe do to order when sort=False. If there's no guarantee about the order, then the docs should say that. What I've observed is that dataframe value_counts sorts by values when sort=False, while dataframe value_counts sorts by the order that the keys first appeared in the data. For example:

import pandas as pd

df = pd.DataFrame(['b', 'a', 'a'])
# dataframe sorts by values, so index is [a, b]
print(df.value_counts(sort=False))
# dataframe sorts by order of row where each value first appears, so index is [b, a]
print(df[0].value_counts(sort=False))

Suggested fix for documentation

Explain what order to expect, if any, when sort=False.

@mvashishtha mvashishtha added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 15, 2023
@phofl phofl added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 23, 2023
@VomV
Copy link
Contributor

VomV commented Apr 22, 2023

take

@VomV
Copy link
Contributor

VomV commented Apr 23, 2023

@phofl I have made the changes but it's failing one of the tests (Ubuntu / Numpy Dev Test(not single_cpu)). This is my first contribution and I would really appreciate any help.

@phofl
Copy link
Member

phofl commented Apr 23, 2023

CI is failing right now on numpy dev, not related to your pr

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 Docs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants