text_plain_output_1.png
import pandas as pd

train_df = pd.read_csv('../input/titanic/train.csv')
test_df = pd.read_csv('../input/titanic/test.csv')
sample_sub = pd.read_csv('../input/titanic/gender_submission.csv')

y = train_df['Survived']
features = train_df.drop(['Survived'], axis=1)

percent_survived = train_df.Survived.sum() / train_df.Survived.count()

num_cols = train_df.select_dtypes(include=['int64', 'float64']).columns
cat_cols = train_df.select_dtypes(include=['object', 'bool']).columns

pd.crosstab(train_df.Sex, train_df.Survived)

survive_percent_male = train_df[train_df.Sex == 'male'].Survived.sum() / train_df[train_df.Sex == 'male'].Survived.count()
survive_percent_female = train_df[train_df.Sex == 'female'].Survived.sum() / train_df[train_df.Sex == 'female'].Survived.count()

pd.crosstab(train_df.Pclass, train_df.Survived)