Skip to content

Commit 660d0f2

Browse files
committed
Add whatsnew
1 parent b8d3c48 commit 660d0f2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

doc/source/whatsnew/v1.1.0.rst

+29
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,35 @@ Indexing
259259
- Bug in :meth:`Series.loc` and :meth:`DataFrame.loc` when indexing with an integer key on a object-dtype :class:`Index` that is not all-integers (:issue:`31905`)
260260
-
261261

262+
Assignment to multiple columns of a DataFrame when some columns do not exist
263+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
264+
265+
Assignment to multiple columns of a :class:`DataFrame` when some of the columns do not exist would previously assign the values to the last column. Now, new columns would be constructed with the right values. (:issue:`13658`)
266+
267+
.. ipython:: python
268+
269+
df = pd.DataFrame({'a': [0, 1, 2], 'b': [3, 4, 5]})
270+
df
271+
272+
*Previous behavior*:
273+
274+
.. code-block:: ipython
275+
276+
In [3]: df[['a', 'c']] = 1
277+
In [4]: df
278+
Out[4]:
279+
a b
280+
0 1 1
281+
1 1 1
282+
2 1 1
283+
284+
*New behavior*:
285+
286+
.. ipython:: python
287+
288+
df[['a', 'c']] = 1
289+
df
290+
262291
Missing
263292
^^^^^^^
264293

0 commit comments

Comments
 (0)