Fill the null values in the dataframe with condition

traindf[traindf['Gender'] == 'female']['Age'].fillna(value=femage,inplace=True)

I've tried to update the null values in the age column in the dataframe with the mean values.Here I tried to replace the null values in the age column of female gender with the female mean age.But the column doesn't get updated.why?

Topic pandas python

Category Data Science


traindf.loc[traindf['Gender'] == 'female','Age'] = traindf.loc[traindf['Gender'] == 'female','Age'].fillna(value=femage)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.