text_plain_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]

category = {'Mr': 1, 'Mrs': 2, 'Miss': 3, 'Master': 4, 'uncommon': 5}
for dataset in concatenate:
    dataset['Title'] = dataset['Title'].map(category)

train_data = train_data.drop('Name', axis=1)
test_data = test_data.drop('Name', axis=1)

concatenate = [train_data, test_data]

for dataset in concatenate:
    dataset['Sex'] = dataset['Sex'].map({'female': 1, 'male': 0}).astype(int)
train_data.head()