How to add a new column to an already existing Pandas frame?

We can add a new column to a dataframe through three different methods:

1. Equating data to the new column:


2. Using the .insert() method

The insert method can be used to add a new column to a dataframe by specifying the position where the column should be inserted, the name of the column, and the data that should be placed in the column. The inplace flag determines whether the changes should be made in place or whether a copy of the data should be returned.


3. Using the .assign() method

The assign method creates a new dataframe by adding a new column to the original dataframe. It does not modify the original dataframe.