title: How to replace NaN values in Pandas conditionally?
body: <p>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: <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy" rel="nofollow noreferrer">http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy</a>
    self._update_inplace(new_data)"</p>
  
  <pre><code>import pandas as pd
  df=pd.read_csv('train.csv')
  df[(df['Sex']=='male') &amp; (df['Age'].apply(np.isnan))]['Age'].fillna(df[df['Sex']=='male']['Age'].mean(),inplace=True)
  </code></pre>