text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png image_output_1.png
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train_data = pd.read_csv('/kaggle/input/titanic/train.csv')

test_data = pd.read_csv('/kaggle/input/titanic/test.csv')

concatenate = [train_data, test_data]

train_data = train_data.drop(['PassengerId', 'Ticket', 'Cabin'], axis=1)
test_data = test_data.drop(['Ticket', 'Cabin'], axis=1)

concatenate = [train_data, test_data]

for dataset in concatenate:
    dataset['Title'] = dataset['Title'].replace('Ms', 'Miss')
    dataset['Title'] = dataset['Title'].replace('Mme', 'Miss')
    dataset['Title'] = dataset['Title'].replace('Mlle', 'Miss')
    dataset['Title'] = dataset['Title'].replace('Sir', 'Mr')
    dataset['Title'] = dataset['Title'].replace(['Col', 'Don', 'Rev', 'Dr', 'Major', 'Lady', 'Capt', 'Countess', 'Jonkheer', 'Dona'], 'uncommon')
train_data[['Title', 'Survived']].groupby('Title').mean().sort_values(by='Survived', ascending=False)