File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ columns.
155155
156156.. warning ::
157157
158- pandas aligns all AXES when setting ``Series `` and ``DataFrame `` from ``.loc ``, and `` .iloc `` .
158+ pandas aligns all AXES when setting ``Series `` and ``DataFrame `` from ``.loc ``.
159159
160160 This will **not ** modify ``df `` because the column alignment is before value assignment.
161161
@@ -172,6 +172,17 @@ columns.
172172 df.loc[:, [' B' , ' A' ]] = df[[' A' , ' B' ]].to_numpy()
173173 df[[' A' , ' B' ]]
174174
175+ However, pandas does not align AXES when setting ``Series `` and ``DataFrame `` from ``.iloc ``
176+ because ``.iloc `` operates by position.
177+
178+ This will modify ``df `` because the column alignment is not done before value assignment.
179+
180+ .. ipython :: python
181+
182+ df[[' A' , ' B' ]]
183+ df.iloc[:, [1 , 0 ]] = df[[' A' , ' B' ]]
184+ df[[' A' ,' B' ]]
185+
175186
176187 Attribute access
177188----------------
You can’t perform that action at this time.
0 commit comments