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

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

train.isnull().sum()

test.isnull().sum()

train.replace({'Sex': {'male': 0, 'female': 1}}, inplace=True)
test.replace({'Sex': {'male': 0, 'female': 1}}, inplace=True)

train.groupby('Embarked').size()

test.groupby('Embarked').size()

train.replace({'Embarked': {'C': 0, 'Q': 1, 'S': 2}}, inplace=True)
test.replace({'Embarked': {'C': 0, 'Q': 1, 'S': 2}}, inplace=True)

print(train.shape)
print(test.shape)