text_plain_output_1.png
import pandas as pd

train = pd.read_csv('../input/train.csv')
test = pd.read_csv('../input/test.csv')

train.isnull().sum()

test.isnull().sum()

train['Age'] = train['Age'].fillna(train['Age'].median())
test['Age'] = test['Age'].fillna(test['Age'].median())
train.drop('Cabin', axis=1, inplace=True)
test.drop('Cabin', axis=1, inplace=True)
train['Embarked'] = train['Embarked'].fillna('S')
test['Fare'] = test['Fare'].fillna(test['Fare'].median())

print(f"[train]Nmaeのユニークな要素: {train['Name'].nunique()}")
print(f"[test]Nmaeのユニークな要素: {test['Name'].nunique()}")
print(f"[train]Sexのユニークな要素: {train['Sex'].nunique()}")
print(f"[test]Sexのユニークな要素: {test['Sex'].nunique()}")
print(f"[train]Ticketのユニークな要素: {train['Ticket'].nunique()}")
print(f"[test]Ticketのユニークな要素: {test['Ticket'].nunique()}")
print(f"[train]Embarkedのユニークな要素: {train['Embarked'].nunique()}")
print(f"[test]Embarkedのユニークな要素: {test['Embarked'].nunique()}")