Skip to content
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

REGR: non-unique, masked dtype index raising IndexError #57061

Merged
merged 8 commits into from
Jan 30, 2024

Conversation

lukemanley
Copy link
Member

@lukemanley lukemanley added Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version labels Jan 25, 2024
@lukemanley lukemanley added this to the 2.2.1 milestone Jan 25, 2024
@@ -1220,6 +1220,7 @@ cdef class MaskedIndexEngine(IndexEngine):
n_alloc *= 2
if n_alloc > max_alloc:
n_alloc = max_alloc
result = np.resize(result, n_alloc)
Copy link
Member

Choose a reason for hiding this comment

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

Is this required to resize here? If so can we get rid of the resize that happens after this branch is completed? Might be misreading but it looks duplicative

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is required. The result size isn't known so I believe the resize check needs to be done each time a new value is set. I don't see a way to avoid it with the current algo.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yea that makes sense. I think its worth making the conditional resize its own function then so we don't have as much duplication

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea - done

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Looking pretty good

pandas/_libs/index.pyx Outdated Show resolved Hide resolved
pandas/_libs/index.pyx Show resolved Hide resolved
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Just a merge conflict otherwise looks good

@mroeschke mroeschke merged commit a302b1b into pandas-dev:main Jan 30, 2024
48 of 50 checks passed
@mroeschke
Copy link
Member

Thanks @lukemanley

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Jan 30, 2024
mroeschke pushed a commit that referenced this pull request Jan 30, 2024
…dex raising IndexError) (#57142)

Backport PR #57061: REGR: non-unique, masked dtype index raising IndexError

Co-authored-by: Luke Manley <lukemanley@gmail.com>
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…7061)

* fix masked indexing regression

* fix test

* fix test

* dedup resizing logic

* add types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Getting "Out of bounds on buffer access" error when .loc indexing a non-unique index with Int64 dtype
3 participants