text_plain_output_1.png
import pandas as pd

titanic_train = pd.read_csv('/kaggle/input/titanic/train.csv')
titanic_test = pd.read_csv('/kaggle/input/titanic/test.csv')
titanic_gender_submission = pd.read_csv('/kaggle/input/titanic/gender_submission.csv').head(10)

columns_to_look = ['PassengerId', 'Name', 'Ticket']
for column in columns_to_look:
    duplicated_qty = titanic_train[column].duplicated().sum()

titanic_train.isna().sum()

parch_missed_age = titanic_train[titanic_train.Age.isna()].Parch.value_counts()
parch_missed_age

age_pivot = titanic_train.pivot_table(index='Parch', values='Age', aggfunc=('mean', 'median'))
age_pivot

titanic_train.Age = titanic_train.groupby('Parch')['Age'].transform(lambda Age_grouped: Age_grouped.fillna(Age_grouped.median()))

titanic_train.Cabin = titanic_train.Cabin.fillna('unknown')

titanic_train[titanic_train.Embarked.isna()]

ticket_embarked = titanic_train[titanic_train.Embarked.isna()]['Ticket'].values[0]
titanic_train.query('Ticket == @ticket_embarked')