File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -507,13 +507,15 @@ of one argument to be called on the ``DataFrame``. A *copy* of the original
507
507
DataFrame is returned, with the new values inserted.
508
508
509
509
.. 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 `
511
511
respects the order of the keyword arguments. You may now use assign in the following way:
512
512
513
513
.. ipython :: python
514
514
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' ])
517
519
518
520
This may subtly change the behavior of your code when you're
519
521
using ``.assign() `` to update an existing column. Prior to Python 3.6,
You can’t perform that action at this time.
0 commit comments