If you want to assign values to multiple new columns, instead of assigning them separately, you can do everything in one line of code with df.assign
.
In the code above, I first created col3
then use col3
to create col4
. Everything is in one line of code.