-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Groupby count doesn't accept sort= keyword #28755
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
we accept **kwargs in these, IIRC mainly to accomodate pandas options like
|
Wouldn't you pass the https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html |
Just came across this while trying to close out some old dask PRs. You can pass a sort kwarg into the groupby and it is on by default. By turning it off you can see that the In [1]: import pandas as pd
...:
...: df = pd.DataFrame({"x": [3, 4, 1, 3, 4, 1], "y": [1, 2, 3, 4, 5, 6]})
...: df
Out[1]:
x y
0 3 1
1 4 2
2 1 3
3 3 4
4 4 5
5 1 6
In [2]: df.groupby("x", sort=False).y.sum(sort=False)
Out[2]:
x
3 5
4 7
1 9
Name: y, dtype: int64
In [3]: df.groupby("x", sort=False).y.sum(sort=True)
Out[3]:
x
3 5
4 7
1 9
Name: y, dtype: int64 If pandas can't catch invalid kwargs because it's passing them along, then I think this issue should be closed. |
I got another issue - groupby. last doesn't accept "min_count" keyword even though the doc says so Is that a bug? Happy to open a bug, just wanted to add the question here first. |
I'm not very familiar with that part of the codebase but since the docs say you should be able to pass the arg I'd say that's a bug. |
Ok I'll report it |
Many groupby aggregations like sum, min, max, mean, and so on take a
sort=
keyword. Count doesn't for some reason.Is this intentional? Is it a bug? I was trying to turn off sorting intermediate results in dask dataframe by default to speed things up a bit (it's also for cudf/RAPIDS work) and ran into this. The inconsistency makes things slightly inconvenient.
The text was updated successfully, but these errors were encountered: