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

train_data = pd.read_csv('/kaggle/input/titanic/train.csv')

test_data = pd.read_csv('/kaggle/input/titanic/test.csv')

df = train_data.drop(columns=['Name', 'Ticket', 'Cabin'])
dft = test_data.drop(columns=['Name', 'Ticket', 'Cabin'])

df.isna().sum()

dft.isna().sum()

df2 = df.copy()
df2.Age = df.Age.fillna(df.Age.mean())
dft2 = dft.copy()
dft2.Age = dft.Age.fillna(dft.Age.mean())
dft2.Fare = dft.Fare.fillna(dft.Fare.mean())
df2.head(6)