-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
DataFrame.sort_index() with ascending passed as a list on a single level index gives wrong result #32334
Labels
Algos
Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff
Bug
good first issue
Index
Related to the Index class or subclasses
Comments
It seems that this works fine: data.sort_index(level=['a'], ascending=False) But the following does not data.sort_index(level=['a'], ascending=[False]) PR welcome |
Possible fix is to do 2 things:
|
take |
take |
aniaan
pushed a commit
to aniaan/pandas
that referenced
this issue
Oct 1, 2020
5 tasks
aniaan
pushed a commit
to aniaan/pandas
that referenced
this issue
Oct 1, 2020
kesmit13
pushed a commit
to kesmit13/pandas
that referenced
this issue
Nov 2, 2020
…ndas-dev#36767) * BUG: Index sortlevel ascending add type checking pandas-dev#32334 * DOC: add v1.2 whatsnew entry pandas-dev#32334 * BUG: adjust judgment conditions, len(ascending) > 1 => len(ascending) != 1 * DOC: adjustment whatsnew Co-authored-by: beanan <fanjianan916@hotmail.com>
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
Bug
good first issue
Index
Related to the Index class or subclasses
I found some problems while using data_frame sort_index, first, create dataframe
Then I want to sort index "a" in descending order,
The above code does not sort index a in descending order, I found the reason is that this dataframe is a single index structure, so when ascending = list is passed, it does not take effect
pandas/pandas/core/frame.py
Lines 4777 to 4783 in bf613c1
Because when it is used, the index may be single index or multi-index. In order to use the effect uniformly,I think there should be a judgment here. If index is a single index and ascending type == list, ascending should be equal to ascending [0],This may be more user friendly
If yes, can I mention pr
The text was updated successfully, but these errors were encountered: