text_html_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # tt processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

df_train = pd.read_csv('../input/spaceship-titanic/train.csv')
df_train

df_test = pd.read_csv('../input/spaceship-titanic/test.csv')
df_test

df_train.isnull().sum()

df_train.isnull().mean() * 100

df_test.isnull().mean() * 100

tt = pd.concat([df_train.drop('Transported', axis=1), df_test])
tt

tt['Age_cat_'] = pd.cut(tt.Age, bins=[0, 5, 12, 18, 50, 150], labels=['Toddler/Baby', 'Child', 'Teen', 'Adult', 'Elderly'])
tt['Age_cat_']

numerical = tt.select_dtypes(exclude=['object', 'category']).columns.to_list()
numerical

tt.isnull().mean() * 100

tt = tt.set_index('PassengerId')
tt

categorical = tt.select_dtypes(['object', 'category']).columns.to_list()
categorical

numerical = tt.select_dtypes(exclude=['object', 'category']).columns.to_list()
numerical

columns = ['Age', 'RoomService', 'FoodCourt', 'ShoppingMall', 'Spa', 'VRDeck', 'sum_exp_', 'mean_exp_']
q, r = divmod(len(columns), 2)
fig, ax = plt.subplots(q, 2, figsize=(18, 10))
for i in range(0, len(columns)):
    q, r = divmod(i, 2)
    sns.kdeplot(data=tt[numerical], x=columns[i], ax=ax[q, r])
plt.show()