-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: missed behavior explaination of sort=False for groupby #47529
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
Comments
Thanks for reporting this @easysam. I'm not sure if |
What happens to the keys is also missing from the User Guide, I think it would be good to add a description there: https://pandas.pydata.org/pandas-docs/dev/user_guide/groupby.html#groupby-sorting |
@datapythonista @rhshadrach pandas/pandas/core/groupby/grouper.py Line 685 in 2b1184d
It seems that the algorithms.factorize is used to calculate the unique keys. The algorithms.factorize use the hashtable.pandas/pandas/core/algorithms.py Line 249 in 2b1184d
However, I met several ".pxi.in" files in the hashtable source code. For example: https://github.com/pandas-dev/pandas/blob/main/pandas/_libs/hashtable_class_helper.pxi.in I also post this problem in stackoverflow, hoping to help others. |
The pxi.in files are built here: Lines 77 to 97 in f4ca4d3
But |
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html
Documentation problem
The docs miss an explanation of sort=False for groupby. Does the order among groups with their keys follow the order of appearance of the keys in the original data frame? Or the groups may be out of order?
Suggested fix for documentation
When setting sort=False for groupby. One may want the order among groups with their keys follows the order of appearance of the keys in the original data frame. Can this be guaranteed?
The text was updated successfully, but these errors were encountered: