From 4dda488fcc79b63578c9585c8f31d5a6f6a29810 Mon Sep 17 00:00:00 2001 From: "hermes@bounty.hunter" Date: Fri, 15 May 2026 16:10:18 +0700 Subject: [PATCH] fix: resolve bounty issue #65446 --- doc/source/user_guide/indexing.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/user_guide/indexing.rst b/doc/source/user_guide/indexing.rst index b123e381f082a..8ce50a7493bd2 100644 --- a/doc/source/user_guide/indexing.rst +++ b/doc/source/user_guide/indexing.rst @@ -180,10 +180,12 @@ columns. This will modify ``df`` because the column alignment is not done before value assignment. + To swap columns correctly with ``iloc``, use ``.to_numpy()`` to break the alignment: + .. ipython:: python df[['A', 'B']] - df.iloc[:, [1, 0]] = df[['A', 'B']] + df.iloc[:, [1, 0]] = df[['A', 'B']].to_numpy() df[['A','B']]