Created
December 14, 2015 21:43
-
-
Save Akramz/0a3fd9ea14262fd3a598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sys import exit | |
import numpy as np | |
data = pd.read_csv('../../train.csv') | |
data = data[['Survived', 'Pclass', 'Sex', 'SibSp', 'Parch', 'Embarked']].dropna() | |
# male = 0 | |
# female = 1 | |
# S = 0 | |
# C = 1 | |
# Q = 2 | |
for index, row in data.iterrows(): | |
if data.loc[index, "Sex"] == 'male': | |
data.loc[index, "Sex"] = 0 | |
if data.loc[index, "Sex"] == 'female': | |
data.loc[index, "Sex"] = 1 | |
if data.loc[index, "Embarked"] == 'S': | |
data.loc[index, "Embarked"] = 0 | |
if data.loc[index, "Embarked"] == 'C': | |
data.loc[index, "Embarked"] = 1 | |
if data.loc[index, "Embarked"] == 'Q': | |
data.loc[index, "Embarked"] = 2 | |
data.to_csv('../train1.csv', sep=',') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment