BUG: iloc on DataFrame with reference is a silent no-op with unsorted indexes#65864
Open
rhshadrach wants to merge 2 commits into
Open
BUG: iloc on DataFrame with reference is a silent no-op with unsorted indexes#65864rhshadrach wants to merge 2 commits into
rhshadrach wants to merge 2 commits into
Conversation
| col_indexer = 0 | ||
| elif len(blk_loc) > 1: | ||
| elif len(inverse) > 1 and np.array_equal( | ||
| inverse, np.arange(len(blk_loc)) |
Member
There was a problem hiding this comment.
do we have a lib.is_range_indexer is something like that we can use here?
Member
|
claude found an existing bug that this changes to a different bug: on main the setitem is (incorrectly) a no-op. Under this PR, it sets the diagonal elements when it should set all the elements. Fine if you want to consider out of scope. |
| # Block.delete in _iset_split_block requires sorted unique | ||
| # locs; inverse maps the requested column order onto the | ||
| # new block (GH#65446) | ||
| blk_loc, inverse = np.unique(blk_loc, return_inverse=True) |
Member
There was a problem hiding this comment.
Suggested change
| blk_loc, inverse = np.unique(blk_loc, return_inverse=True) | |
| blk_loc_unique, inverse = np.unique(blk_loc, return_inverse=True) |
So we keep the original blk_loc? (eg I would assume the values = values[blk_locs] below needs to us the original blk_locs?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This appears to me to be a somewhat severe bug - using iloc has no impact when there is another reference to the DataFrame.
The only thing that makes it not so severe is that the indices have to be not strictly increasing. I believe this was introduced in 2.1 with CoW enabled in #51435 but haven't run a git bisect here.