Skip to content

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

Merged
merged 1 commit into from
Apr 24, 2019

Conversation

jayanthkaturi
Copy link
Contributor

@jayanthkaturi jayanthkaturi commented Apr 11, 2019

@codecov
Copy link

codecov bot commented Apr 14, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@190a69e). Click here to learn what that means.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #26054   +/-   ##
=========================================
  Coverage          ?   40.74%           
=========================================
  Files             ?      175           
  Lines             ?    52487           
  Branches          ?        0           
=========================================
  Hits              ?    21388           
  Misses            ?    31099           
  Partials          ?        0
Flag Coverage Δ
#single 40.74% <0%> (?)
Impacted Files Coverage Δ
pandas/core/indexes/multi.py 33.87% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 190a69e...2caee96. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 14, 2019

Codecov Report

Merging #26054 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 90.53% <100%> (ø) ⬆️
#single 40.7% <0%> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/multi.py 95.62% <100%> (+0.01%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.9% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b62e9ae...5dec93f. Read the comment docs.

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'])
Copy link
Contributor

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

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)
Copy link
Contributor

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

primary = []
primshp = []

# Add the required codes and shape
Copy link
Contributor

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)

@pep8speaks
Copy link

pep8speaks commented Apr 16, 2019

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

Copy link
Contributor

@jreback jreback left a 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

@jreback jreback added this to the 0.25.0 milestone Apr 20, 2019
@jayanthkaturi jayanthkaturi force-pushed the master branch 2 times, most recently from 107a575 to d75ac48 Compare April 21, 2019 03:11
@jayanthkaturi
Copy link
Contributor Author

this is same/duplicate as the original issue. I updated the PR, pls let me know if anything else is required. Thanks!

@@ -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`)
Copy link
Contributor

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

Copy link
Contributor Author

@jayanthkaturi jayanthkaturi Apr 22, 2019

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@jreback
Copy link
Contributor

jreback commented Apr 23, 2019

also pls merge master

…6053)

    - (lev - i) will be out of bounds for pop if the first index dim is to be sorted last
@jreback jreback merged commit 33e05d7 into pandas-dev:master Apr 24, 2019
@jreback
Copy link
Contributor

jreback commented Apr 24, 2019

thanks @jayanthkaturi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sort_index throws IndexError for some permutations
4 participants