File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ columns.
155
155
156
156
.. warning ::
157
157
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 ``.
159
159
160
160
This will **not ** modify ``df `` because the column alignment is before value assignment.
161
161
@@ -172,6 +172,17 @@ columns.
172
172
df.loc[:, [' B' , ' A' ]] = df[[' A' , ' B' ]].to_numpy()
173
173
df[[' A' , ' B' ]]
174
174
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
+
175
186
176
187
Attribute access
177
188
----------------
You can’t perform that action at this time.
0 commit comments