text_plain_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')
target = train['Survived']
m = pd.DataFrame(test['PassengerId'])

import seaborn as sns
import matplotlib.pyplot as plt
dataset = pd.concat([train.drop('Survived', axis=1), test])
dataset.isnull().sum()

a = dataset.groupby('Pclass')['Age'].median()
dataset['Age'] = dataset['Age'].fillna(dataset['Pclass'].map(a))
a = dataset.groupby('Pclass')['Fare'].median()
dataset['Fare'] = dataset['Fare'].fillna(dataset['Pclass'].map(a))
dataset['Embarked'].fillna('S', inplace=True)

dataset['Passenger'] = dataset['SibSp'] + dataset['Parch'] + 1
dataset