3.14. Applying functions on Dataframe#

import pandas as pd
import numpy as np
df=pd.DataFrame({
'Name':['Sahil Choudhary','Sonia Choudhary','Sourav','Vishal'],
'Age':[10,20,30,40],
'Gender':['M','F','M','M'],
'City':['J','K','L','P'],
'Place of Work':[True,False,False,True]
}
)
df
Name Age Gender City Place of Work
0 Sahil Choudhary 10 M J True
1 Sonia Choudhary 20 F K False
2 Sourav 30 M L False
3 Vishal 40 M P True
def process(x):
    # Here x is series,you have passed entire col
    return 'a'
df['New']=process(df['Name'])