Pandas version checks
- [X] I have checked that the issue still exists on the latest versions of the docs on
main
here
Location of the documentation
- https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.value_counts.html
- https://pandas.pydata.org/docs/reference/api/pandas.Series.value_counts.html
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
.
Comment From: VomV
take
Comment From: VomV
@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.
Comment From: phofl
CI is failing right now on numpy dev, not related to your pr