Skip to content

Commit b3b822f

Browse files
committed
pandas-dev#13950 - Updated documentation on pandas alignment when setting
1 parent 2e881c3 commit b3b822f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

doc/source/user_guide/indexing.rst

+11-1
Original file line numberDiff line numberDiff 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,16 @@ columns.
172172
df.loc[:, ['B', 'A']] = df[['A', 'B']].to_numpy()
173173
df[['A', 'B']]
174174
175+
However, pandas does not aligns AXES when setting ``Series`` and ``DataFrame`` from ``.iloc``.
176+
177+
This will modify ``df`` because the column alignment is not done before value assignment.
178+
179+
.. ipython:: python
180+
181+
df[['A', 'B']]
182+
df.iloc[:, [1, 0]] = df[['A', 'B']]
183+
df[['A','B']]
184+
175185
176186
Attribute access
177187
----------------

0 commit comments

Comments
 (0)