Skip to content

DOC: fix iloc column swap example in indexing guide (bounty #65446)#65646

Open
bomlinux92-byte wants to merge 1 commit into
pandas-dev:mainfrom
bomlinux92-byte:bounty-fix-65446-05152026
Open

DOC: fix iloc column swap example in indexing guide (bounty #65446)#65646
bomlinux92-byte wants to merge 1 commit into
pandas-dev:mainfrom
bomlinux92-byte:bounty-fix-65446-05152026

Conversation

@bomlinux92-byte
Copy link
Copy Markdown

Summary

Fix for BOUNTY #65446 — DOC: Swapping values with iloc causes aligns axes, wrong example in docs

Root cause

The documentation example does NOT properly swap columns. Pandas aligns on column labels during assignment, even when using for selection. The result is that columns are assigned by label match rather than position, so the swap does not occur as expected.

Fix

Updated the documentation example to use to break the alignment:

This ensures the assignment is done positionally, achieving the expected column swap behavior.

Verification

Documentation now correctly shows that is required for positional column swapping with . The corrected example produces the expected output showing columns properly swapped.

Closes #65446

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOC: Swapping values with iloc causes aligns axes, wrong example in docs

1 participant