text_plain_output_1.png image_output_1.png
import pandas as pd

train_df = pd.read_csv('../input/train.csv')
test_df = pd.read_csv('../input/test.csv')

def immute_ages(cols):
    Age = cols[0]
    Pclass = cols[1]
    if pd.isnull(Age):
        if Pclass == 1:
            return 38
        if Pclass == 2:
            return 30
        else:
            return 25
    else:
        return Age

train_df[pd.isnull(train_df['Embarked'])]