How to add a new column to an existing DataFrame?
You can add a new column to an existing pandas DataFrame by using the assign() method or the [] notation.
Using the assign() method:
df = df.assign(new_column_name=new_column_values)Using the [] notation:
df['new_column_name'] = new_column_valuesNote that new_column_values should be a list or array of the same length as the number of rows in the DataFrame.