text_plain_output_1.png
from sklearn.preprocessing import LabelEncoder

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

import seaborn as sns

dataset = pd.read_csv('../input/train.csv')
actual_data = dataset
actual_data

dataset.dtypes

def clean_data(dataset):
    data = dataset.dropna()
    data = data.drop('PassengerId', axis=1)
    data = data.drop('Name', axis=1)
    data = data.drop('Ticket', axis=1)
    return data

def encode_categorical_feautures(dataset):
    for coloumns in dataset.columns:
        enc = LabelEncoder()
        enc.fit(dataset[coloumns])
        dataset[coloumns] = enc.fit_transform(dataset[coloumns])
    return dataset

dataset = clean_data(dataset)
dataset = encode_categorical_feautures(dataset)

survived = dataset[dataset['Survived'] == 1]
survived_males = survived[survived['Sex'] == 0]
survived_females = survived[survived['Sex'] == 1]
print('Out of Total Passengers ', len(dataset))
print('Males Survived :', len(survived_males))
print('Females Survived :', len(survived_females))
sns.set_style('whitegrid')
sns.barplot(x=['Males', 'Females'], y=[len(survived_males), len(survived_females)])