Skip to content

Commit 390a8d2

Browse files
author
datajanko
committed
improves whatsnew on ipython block and explanation of dependent kwargs
1 parent f87570d commit 390a8d2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

doc/source/whatsnew/v0.23.0.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ Please note that the string `index` is not supported with the round trip format,
181181
``.assign()`` accepts dependent arguments
182182
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
183183

184-
The :func:`DataFrame.assign()` now accepts dependent kwargs. (:issue:`14207`)
184+
The :func:`DataFrame.assign()` now accepts dependent kwargs for python version later than 3.6 (see also `PEP 468
185+
<https://www.python.org/dev/peps/pep-0468/>`_). Now the keyword-value pairs passed to `.assign()` may depend on their predecessors if the values are callables. (:issue:`14207`)
185186

186-
Specifically, defining a new column inside ``.assign()`` may be referenced in the same assign statement if a callable is used. For example
187+
.. ipython:: python
187188

188-
.. ipython:: python
189+
df = pd.DataFrame({'A': [1, 2, 3]})
190+
df
191+
df.assign(B=df.A, C=lambda x:x['A']+ x['B'])
189192

190-
In [3]: df = pd.DataFrame({'A': [1, 2, 3]})
191-
192-
In [4]: df.assign(B=df.A, C=lambda x:x['A']+ x['B'])
193193
.. warning::
194194

195195
This may subtly change the behavior of your code when you're
@@ -213,7 +213,7 @@ New Behaviour:
213213

214214
.. ipython:: python
215215

216-
In [5]: df.assign(A=df.A+1, C= lambda df: df.A* -1)
216+
df.assign(A=df.A+1, C= lambda df: df.A* -1)
217217

218218
.. _whatsnew_0230.enhancements.other:
219219

0 commit comments

Comments
 (0)