Assign Values to Multiple Columns in a pandas DataFrame

df.assign allows you to assign values to multiple new columns in one line of code.

In the code above, I first created col3 then usecol3 to create col4 in one line of code.

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran