pandas create a new column code example
Example 1: how to add a column to a pandas df
df.insert(location, column_name, list_of_values)
df.insert(0, 'new_column', ['a','b','c'])
df['new_column_name'] = value
Example 2: how to add new column to dataframe
import pandas as pd
data = {'Name': ['Jai', 'Princi', 'Gaurav', 'Anuj'],
'Height': [5.1, 6.2, 5.1, 5.2],
'Qualification': ['Msc', 'MA', 'Msc', 'Msc']}
df = pd.DataFrame(data)
address = ['Delhi', 'Bangalore', 'Chennai', 'Patna']
df['Address'] = address
df