application_vnd.jupyter.stderr_output_1.png
from sklearn.model_selection import train_test_split

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

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

X = df.drop('Transported', 1)
y = df['Transported'].apply(int)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)

def trans(df):
    df['Age'].fillna(df.Age.mean(), inplace=True)
    df['RoomService'].fillna(df.RoomService.mean(), inplace=True)
    df['FoodCourt'].fillna(df.FoodCourt.mean(), inplace=True)
    df['ShoppingMall'].fillna(df.ShoppingMall.mean(), inplace=True)
    df['Spa'].fillna(df.Spa.mean(), inplace=True)
    df['VRDeck'].fillna(df.VRDeck.mean(), inplace=True)
    df['HomePlanet'].fillna(df['HomePlanet'].mode()[0], inplace=True)
    df['Destination'].fillna(df['Destination'].mode()[0], inplace=True)
    df['CryoSleep'].fillna(df['CryoSleep'].mode()[0], inplace=True)
    df['VIP'].fillna(df['VIP'].mode()[0], inplace=True)
    df['Cabin'].fillna(df['Cabin'].mode()[0], inplace=True)
    df['CryoSleep'] = df['CryoSleep'].apply(int)
    df[['Deck', 'Num', 'Side']] = df['Cabin'].str.split('/', expand=True)
    df['Num'] = df['Num'].astype(int)
    return df

dfz = trans(X_train)
dfz.head()