I'm using famous Titanic dataset for my first Kaggle problem. I'm getting stuck in dataset. I want to replace NaN values of Age gender wise e.g. missing values for 'male' should get replaced by average age of Male and vice-versea. While my code is running fine but getting an exception as following: "SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self._update_inplace(new_data)"
import pandas as pd
df=pd.read_csv('train.csv')
df[(df['Sex']=='male') & (df['Age'].apply(np.isnan))]['Age'].fillna(df[df['Sex']=='male']['Age'].mean(),inplace=True)