We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
value_counts does not respect sort=False from groupby:
sort=False
df = pd.DataFrame({'a': [2, 1, 1], 'b': [3, 4, 3]}) gb = df.groupby('a', sort=False) result = gb.value_counts() print(result) # a b # 1 4 1 # 3 1 # 2 3 1 # Name: count, dtype: int64
In the above, the groups should appear with a=2 first and a = 1 second.
a=2
a = 1
If the columns of your DataFrame are integers, the method may sort by these instead.
df = pd.DataFrame({'a': [2, 1, 1], 0: [3, 4, 3]}) gb = df.groupby('a', sort=False) result = gb.value_counts() print(result) # a 0 # 2 3 1 # 1 3 1 # 4 1 # Name: count, dtype: int64
The text was updated successfully, but these errors were encountered:
Closed by #56016
Sorry, something went wrong.
rhshadrach
No branches or pull requests
value_counts does not respect
sort=False
from groupby:In the above, the groups should appear with
a=2
first anda = 1
second.If the columns of your DataFrame are integers, the method may sort by these instead.
The text was updated successfully, but these errors were encountered: