def include_mean():
    if pd.isnull('Age'):
        if 'Pclass'==1:
            return 38
        elif 'Pclass'==2:
            return 30
        elif 'Pclass'==3:
            return 25
        else: return 'Age'
train['Age']=train[['Age','Pclass']].apply(include_mean(),axis=1)
why is the above code giving me a type error.
 TypeError: ("'NoneType' object is not callable", 'occurred at index 0')
I now know the right code which is
def impute_age(cols):
    Age = cols[0]
    Pclass = cols[1]
    if pd.isnull(Age):
if Pclass == 1:
            return 37
elif Pclass == 2:
            return 29
else:
            return 24
else:
        return Age
train['Age'] = train[['Age','Pclass']].apply(impute_age,axis=1)
Now I want to know why are the changes required i.e. the exact reasons behind them. What is 'cols' doing here.
 
     
     
     
    