pandas.DataFrame.assign

pandas 3.1.1 · DataFrame · method

Build a new DataFrame with added or replaced columns. Callables can use columns assigned earlier in the same call.

Call syntax

DataFrame.assign(**kwargs)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
**kwargs Optional
Additional keyword arguments

Each keyword becomes a column name. Use a value directly or a callable receiving the DataFrame.

Returns

DataFrame