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

train_df = pd.read_csv('../input/train.csv')
test_df = pd.read_csv('../input/test.csv')
test_y = pd.read_csv('../input/gender_submission.csv')
X_train = train_df[['Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked']]
sex = pd.get_dummies(X_train['Sex'])
X_train = X_train.drop(['Sex'], axis=1)
X_train = X_train.join(sex)
embarked = pd.get_dummies(X_train['Embarked'])
X_train = X_train.drop(['Embarked'], axis=1)
X_train = X_train.join(embarked)
Y_train = train_df.drop(['PassengerId', 'Ticket', 'Cabin', 'Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked', 'Name'], axis=1)
X_test = test_df[['Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked']]
sex = pd.get_dummies(X_test['Sex'])
X_test = X_test.drop(['Sex'], axis=1)
X_test = X_test.join(sex)
embarked = pd.get_dummies(X_test['Embarked'])
X_test = X_test.drop(['Embarked'], axis=1)
X_test = X_test.join(embarked)
Y_test = test_y.drop('PassengerId', axis=1).copy()

class_1_pass = train_df[train_df['Pclass'] == 1]
print('1st Class Passengers :')
print(class_1_pass['Fare'].count())
class_1_pass_sur = class_1_pass[class_1_pass['Survived'] == 1]
print('Survivor of 1st class passengers: ')
print(class_1_pass_sur['Fare'].count())
class_1_pass_female = class_1_pass[class_1_pass['Sex'] == 'female']
print('No of female in 1st class : ')
print(class_1_pass_female['PassengerId'].count())
class_1_pass_sur_female = class_1_pass_sur[class_1_pass_sur['Sex'] == 'female']
print('Female survivor of 1st class passengers :')
print(class_1_pass_sur_female['PassengerId'].count())
class_1_female_sur_rate = class_1_pass_sur_female['PassengerId'].count() / class_1_pass_female['PassengerId'].count()
print('1st class female survivor rate :')
print(class_1_female_sur_rate)
class_1_pass_child = class_1_pass[class_1_pass['Age'] < 15]
print('No of childrn in 1st class : ')
print(class_1_pass_child['PassengerId'].count())
class_1_pass_sur_child = class_1_pass_sur[class_1_pass_sur['Age'] < 15]
print('Children survivor of 1st class passengers')
print(class_1_pass_sur_child['PassengerId'].count())
class_1_child_sur_rate = class_1_pass_sur_child['PassengerId'].count() / class_1_pass_child['PassengerId'].count()
print('1st class child survivor rate :')
print(class_1_child_sur_rate)