Repository navigation
Conversation
…labels Avoid pandas label-based alignment during comp_data insertion by temporarily using RangeIndex during coordinate conversion, restoring the original index at the end. Fixes mwaskom#4036
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.
Fixes #4036
Problem
When plotting a DataFrame that has duplicate index labels and contains missing values (`NaN`) in coordinate variables, `VectorPlotter.comp_data` drops missing values per-coordinate and inserts the converted Series into `comp_data`. Because `comp_data` retains the original duplicate index, pandas aligns on index labels, duplicating valid coordinate values across rows with duplicate index labels and silently fabricating points that do not exist in the input data.
Solution
Temporarily set `comp_data.index = pd.RangeIndex(len(comp_data))` and convert coordinates using matching integer range indices on `col` and `converters`. This ensures that pandas performs 1-to-1 positional assignment without label broadcasting during column insertion. The original user index is restored at the end of `comp_data`.
Testing
AI Disclosure
I used an AI coding assistant (Google Antigravity) to help investigate the pandas index alignment mechanism and draft the fix and regression test. I have reviewed and verified all code changes and test runs locally.