I made some function like this: data['Age'] = data[['Age',School]].apply(age_implementation, axis = 1)
by doing so I want to full NaN values in "Age" column based on School of child and this is the definitione of my "age_implementation" function.
Nevertheless when I try to apply function using code above nothing changes, how can I apply this function ?
Function:
def age_implementation(cols):
Age = cols[0]
School= cols[1]
if pd.isnull(Age):
if School== 1:
return 10
elif School== 2:
return 15
elif School== 3:
return 20
else:
return Age
Data:
data = pd.DataFrame("School":{1,2,3,1,2,2}, "Age":{NaN, NaN, 20, NaN, NaN, 15})