You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.23.0.txt
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -125,15 +125,15 @@ Current Behavior
125
125
``.assign()`` accepts dependent arguments
126
126
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127
127
128
-
The :func:`DataFrame.assign()` now accepts dependent kwargs. (:issue:`14207`)
128
+
The :func:`DataFrame.assign()` now accepts dependent kwargs for python version later than 3.6 (see also `PEP 468
129
+
<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`)
129
130
130
-
Specifically, defining a new column inside ``.assign()`` may be referenced in the same assign statement if a callable is used. For example
131
+
.. ipython:: python
131
132
132
-
.. ipython:: python
133
+
df = pd.DataFrame({'A': [1, 2, 3]})
134
+
df
135
+
df.assign(B=df.A, C=lambda x:x['A']+ x['B'])
133
136
134
-
In [3]: df = pd.DataFrame({'A': [1, 2, 3]})
135
-
136
-
In [4]: df.assign(B=df.A, C=lambda x:x['A']+ x['B'])
137
137
.. warning::
138
138
139
139
This may subtly change the behavior of your code when you're
@@ -157,7 +157,7 @@ New Behaviour:
157
157
158
158
.. ipython:: python
159
159
160
-
In [5]: df.assign(A=df.A+1, C= lambda df: df.A* -1)
0 commit comments