Skip to content

Commit 9ff161b

Browse files
author
datajanko
committed
fixes dsintro entry for assign
- improved example in warning - linked reference to docstring of assign
1 parent 144b832 commit 9ff161b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

doc/source/dsintro.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,15 @@ of one argument to be called on the ``DataFrame``. A *copy* of the original
507507
DataFrame is returned, with the new values inserted.
508508

509509
.. warning::
510-
Starting from Python 3.6 ``**kwargs`` is an ordered dictionary and :func`DataFrame.assign`
510+
Starting from Python 3.6 ``**kwargs`` is an ordered dictionary and :func:`DataFrame.assign`
511511
respects the order of the keyword arguments. You may now use assign in the following way:
512512

513513
.. ipython:: python
514514
515-
In [1]: df.assign(C = lambda x: x['A'] + x['B'],
516-
D = lambda x: x['A'] + x['C'])
515+
df_warn = pd.DataFrame({"A": [1, 2, 3],
516+
"B": [4, 5, 6]})
517+
df_warn.assign(C=lambda x: x['A'] + x['B'],
518+
D=lambda x: x['A'] + x['C'])
517519
518520
This may subtly change the behavior of your code when you're
519521
using ``.assign()`` to update an existing column. Prior to Python 3.6,

0 commit comments

Comments
 (0)