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

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

test_data = pd.read_csv('/kaggle/input/titanic/test.csv')

df = train_data.drop(columns=['Name', 'Ticket', 'Cabin'])
dft = test_data.drop(columns=['Name', 'Ticket', 'Cabin'])

DF = pd.concat([df, dft])
survivors = DF[DF.Survived == 1]
women_survivors = DF[(DF.Survived == 1) & (DF.Sex == 'female')]
percent_women_survivors = len(women_survivors) / len(survivors)
men_survivors = DF[(DF.Survived == 1) & (DF.Sex == 'male')]
percent_men_survivors = len(men_survivors) / len(survivors)

class1_survivors = DF[(DF.Survived == 1) & (DF.Pclass == 1)]
percent_class1_survivors = len(class1_survivors) / len(survivors)
class2_survivors = DF[(DF.Survived == 1) & (DF.Pclass == 2)]
percent_class2_survivors = len(class2_survivors) / len(survivors)
class3_survivors = DF[(DF.Survived == 1) & (DF.Pclass == 3)]
percent_class3_survivors = len(class3_survivors) / len(survivors)
print(percent_class1_survivors, percent_class2_survivors, percent_class3_survivors)