# Create a groupby object: by_sex_class by_sex_class = titanic.groupby([\"sex\",\"pclass\"]).count() # Write a function that imputes median def impute_median(series):
I will recommend using this
df['age'].fillna(df.groupby(["sex","pclass"])['age'].transform('median'),inplace=True)