Pandas Dataframe.assign() method assigns new columns to a DataFrame, returning the new object (a copy) with the new columns added to the original ones. Please be careful while assigning the new columns because existing columns that are re-assigned will be overwritten.
To assign new columns to a DataFrame, use the Pandas assign() method. The assign() returns the new object with all original columns in addition to new ones. Existing columns that are re-assigned will be overwritten. The length of the newly assigned column must match the number of rows in the DataFrame.
DataFrame.assign(**kwargs)
#pandas #python