-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: sort_index throws IndexError for some permutations (#26053) #26054
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #26054 +/- ##
=========================================
Coverage ? 40.74%
=========================================
Files ? 175
Lines ? 52487
Branches ? 0
=========================================
Hits ? 21388
Misses ? 31099
Partials ? 0
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #26054 +/- ##
==========================================
- Coverage 91.98% 91.98% -0.01%
==========================================
Files 175 175
Lines 52372 52375 +3
==========================================
- Hits 48177 48176 -1
- Misses 4195 4199 +4
Continue to review full report at Codecov.
|
pandas/tests/frame/test_sorting.py
Outdated
res = df.sort_index(level='A', sort_remaining=False) | ||
assert_frame_equal(df, res) | ||
|
||
res = df.sort_index(level=['A', 'B'], sort_remaining=False) | ||
assert_frame_equal(df, res) | ||
|
||
res = df.sort_index(level=['C', 'B', 'A']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you put a comment here with the issue number
pandas/tests/frame/test_sorting.py
Outdated
res = df.sort_index(level='A', sort_remaining=False) | ||
assert_frame_equal(df, res) | ||
|
||
res = df.sort_index(level=['A', 'B'], sort_remaining=False) | ||
assert_frame_equal(df, res) | ||
|
||
res = df.sort_index(level=['C', 'B', 'A']) | ||
assert_frame_equal(df.iloc[[1, 0]], res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write these as
expected = ....
assert_frame_equal(result, expected)
need also to fix the others in this test
pandas/core/indexes/multi.py
Outdated
primary = [] | ||
primshp = [] | ||
|
||
# Add the required codes and shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write both of these as a list comprehensiion (as was original, just w/o the pop)
Hello @jayanthkaturi! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-04-24 20:09:41 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the original issue a duplicate of what you have here (if it is, that's ok), otherwise pls add it.
pls add a what's new note in Bug fixes, reshaping section
107a575
to
d75ac48
Compare
this is same/duplicate as the original issue. I updated the PR, pls let me know if anything else is required. Thanks! |
doc/source/whatsnew/v0.25.0.rst
Outdated
@@ -405,6 +405,7 @@ Reshaping | |||
- Bug in :func:`merge` where merging with equivalent Categorical dtypes was raising an error (:issue:`22501`) | |||
- Bug in :class:`DataFrame` constructor when passing non-empty tuples would cause a segmentation fault (:issue:`25691`) | |||
- Bug in :func:`pandas.cut` where large bins could incorrectly raise an error due to an integer overflow (:issue:`26045`) | |||
- Bug in :func:`DataFrame.sort_index` where sorting with the first index level last was throwing an error (:issue:`26053`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not giving me any idea what you are changing, can you reword a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug in :func:
DataFrame.sort_index
where an error is thrown when a multi-indexed
DataFrame is sorted on all levels with the initial level sorted last (:issue:26053
)
is this one better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
also pls merge master |
…6053) - (lev - i) will be out of bounds for pop if the first index dim is to be sorted last
thanks @jayanthkaturi |
git diff upstream/master -u -- "*.py" | flake8 --diff