text_html_output_1.png
from sklearn.preprocessing import LabelEncoder

from sklearn.preprocessing import LabelEncoder

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.iloc[:, :-1]
y = df.iloc[:, 13]
x = x.drop(['Cabin', 'Name', 'PassengerId'], axis='columns')
lvl = LabelEncoder()
x['CryoSleep'] = lvl.fit_transform(x['CryoSleep'])
x['VIP'] = lvl.fit_transform(x['VIP'])
dummies = pd.get_dummies(x['HomePlanet'])
x = pd.concat([x, dummies], axis='columns')
dummies = pd.get_dummies(x['Destination'])
x = pd.concat([x, dummies], axis='columns')
x = x.drop(['HomePlanet', 'Destination'], axis='columns')
x.isnull().sum()
null_having = ['Age', 'RoomService', 'FoodCourt', 'ShoppingMall', 'Spa', 'VRDeck']
mode_values = x[null_having].mode().iloc[0]
mode_values
x[null_having] = x[null_having].fillna(mode_values)
x

df