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\' sh
import pandas as pd import numpy as np df = pd.read_csv('train.csv') df['Age'].fillna(df.groupby(["Sex"])["Age"].transform(np.mean), inplace=True)
Maybe this was something you were trying to do? I didn't get any warning though. Have a look at my blog post too if necessary.