text_plain_output_1.png
import math

import matplotlib.pyplot as plt

import pandas as pd

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

import seaborn as sns

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

train_data.shape

train_data = train_data.loc[:, train_data.isnull().sum() / len(train_data) * 100 < 60]

train_data.drop(['PassengerId', 'Name'], axis=1, inplace=True)

def fill_Missing_Values(df):
    miss_col = df.isnull().sum()
    miss_col = miss_col[miss_col > 0]
    for column in miss_col.index:
        if df[column].dtype.name == 'object':
            df[column].fillna(df[column].mode()[0], inplace=True)
        elif df[column].dtype.name == 'float64' or df[column].dtype.name == 'int64' or df[column].dtype.name == 'int32':
            df[column] = df[column].fillna(df[column].median())
    return df

train_data = fill_Missing_Values(train_data)

train_data.drop(['Ticket'], axis=1, inplace=True)

train_data.dtypes

rows = int(math.ceil(len(['Survived', 'Pclass', 'Sex', 'SibSp', 'Parch', 'Embarked']) / 4))
cols = 4

#Heatmap
f, ax = plt.subplots(figsize=(10, 10))
sns.heatmap(train_data.corr(), 
            xticklabels=train_data.corr().columns.values,
            yticklabels=train_data.corr().columns.values,annot= True)

bottom, top = ax.get_ylim()
ax.set_ylim(bottom + 0.5, top - 0.5)

plt.show()

objList = train_data.select_dtypes(include='object').columns
print(objList)