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')
submission_df = pd.read_csv('/kaggle/input/titanic/gender_submission.csv')

data = pd.concat([train.assign(ind='train'), test.assign(ind='test')], ignore_index=True)

data['Age'] = data.groupby(['Sex', 'Pclass'])['Age'].apply(lambda x: x.fillna(x.median()))
data['Age'] = data['Age'].astype(int)
data.loc[data['Age'] <= 15, 'Age'] = 0
data.loc[(data['Age'] > 15) & (data['Age'] <= 30), 'Age'] = 1
data.loc[(data['Age'] > 30) & (data['Age'] <= 45), 'Age'] = 2
data.loc[(data['Age'] > 45) & (data['Age'] <= 60), 'Age'] = 3
data.loc[data['Age'] > 60, 'Age'] = 4

data.describe(include='all')