# -*- coding: utf-8 -*-
"""
Created on Fri Nov 27 23:26:27 2015

@author: Owner
"""

import pandas as pd
import numpy as np
 
#pd.set_option('display.max_rows',5000)
 
roster = pd.read_csv("data/cfl_data/cfl_roster.csv")
 
height = roster.iloc[0:,9]
weight = roster.iloc[0:,10]
location = roster.iloc[0:,12]
ID = roster.iloc[0:,0]
 
hometown = location.str.split(',').str.get(0)
state = location.str.split(',').str.get(1)
 
state = state.str.replace('California|CA|CA. ', 'CA')
state =state.str.replace('Ontario', 'ON' )
state =state.str.replace('Saskatchewan', 'SK')
state =state.str.replace('Florida', 'FL')
state =state.str.replace('Mississippi', 'MS')
state =state.str.replace('Montana', 'MT')
state =state.str.replace('North Carolina|NC.|N.C.', 'NC')
state =state.str.replace('Jamaica|Jamiaca|JM  ','JM')
state =state.str.replace('Texas', 'TX')
state =state.str.replace('Quebec|Québec', 'QC')
state =state.str.replace('Illinois', 'IL')
state =state.str.replace('New Jersey', 'NJ')
state =state.str.replace('Louisiana', 'LA')
state =state.str.replace('Manitoba', 'MB')
state =state.str.replace('Nigeria', 'NG')
state =state.str.replace('D.C.|D.C', 'DC')
state =state.str.replace('Alabama', 'AL')
state =state.str.replace('New York|N.Y.|NY.', 'NY')
state =state.str.replace('Tennessee', 'TN')
state =state.str.replace('Hawaii|Hawai"i', 'HI')
state =state.str.replace('Indiana', 'IN')
state =state.str.replace('Ireland', 'IE')
state =state.str.replace('Georgia', 'GE')
#state =state.str.replace('C-B/BC', None)
state =state.str.replace('Oklahoma', 'OK')
state =state.str.replace('Ghana', 'GH')
#state =state.str.replace('Zaire', None)
state =state.str.replace('Argentina', 'AR')
state =state.str.replace('Poland', 'PL')
state =state.str.replace('Ohio', 'OH')
state =state.str.replace('Bahamas', 'BS')
state =state.str.replace('B.C.|British Columbia', 'BC')
state =state.str.replace('Michigan','MI')
state =state.str.replace('Washington|Wash.', 'WA')
state =state.str.replace('Alberta', 'AB')
state =state.str.replace('Chad', 'TD')
state =state.str.replace('England', 'UK')
state =state.str.replace('Arkansas', 'AR')
state =state.str.replace('Guyana', 'GY')
state =state.str.replace('Virginia', 'VA')
state =state.str.replace('Minnesota|Minn.', 'MN')
state =state.str.replace('Iran', 'IR')
state =state.str.replace('Germany', 'DE')
state =state.str.replace('Japan', 'JP')
state =state.str.replace('Haiti', 'HT')
state =state.str.replace('Phillipines', 'PH')
state =state.str.replace('Lebanon', 'LB')
state =state.str.replace('Nevada', 'NV')
state =state.str.replace('Gabon', 'GA')
state =state.str.replace('Arizona', 'AZ')
#state =state.str.replace('east africa', None)
state =state.str.replace('Nebraska', 'NE')
state =state.str.replace('South Korea', 'KP')
state =state.str.replace('S.C.|South Carolina', 'SC')
state =state.str.replace('Connecticut', 'CT')
#state =state.str.replace('Canada', None)
state =state.str.replace('Oregon', 'OR')
state =state.str.replace('Maryland', 'MD')
state =state.str.replace('Trinidad', 'TT')
state =state.str.replace('France', 'FR')
state =state.str.replace('Africa', 'CF')
state =state.str.replace('Nicaragua', 'NI')
state =state.str.replace('Cuba', 'CU')
state =state.str.replace('Rwanda', 'RW')
state =state.str.replace('Afghanistan', 'AF')
state =state.str.replace('Congo', 'CG')
state =state.str.replace('Idaho', 'ID')
state =state.str.replace('Venezuela', 'VE')
state =state.str.replace('new zealand', 'NZ')
#state =state.str.replace('Fla', None)
state =state.str.replace('costa rica', 'CR')
state =state.str.replace('liberia', 'LR')
state =state.str.replace('Serbia', 'RS')
state =state.str.replace('Cameroon', 'CM')
state =state.str.replace('Missouri', 'MO')
state =state.str.replace('Kentucky', "KY")
#state =state.str.replace('City', None)
state =state.str.replace('Pennsylvania|PA.', 'PA')
state =state.str.replace('IND', 'IN')
state =state.str.replace('Netherlands', 'AN')
state =state.str.replace('Australia', 'AU')
#state =state.str.replace('1990', None)
state =state.str.replace('Honduras', 'HN')
state =state.str.replace('Panama', 'PA')
#state =state.str.replace('Petersburg', None)
state =state.str.replace('Virgina', 'VA')
state =state.str.replace('WI.', 'WI')
state =state.str.replace('IL.', 'IL')
state =state.str.replace('FL.', 'FL')
state =state.str.replace('VA.', 'VA')
state =state.str.replace('Georgie', 'GA')
state =state.str.replace('Miss.', 'MS')
state =state.str.replace('OH ', 'OH')
state =state.str.replace('Wisconsin', 'WI')
state =state.str.replace('West VA', 'VA')
state =state.str.replace('Kansas', 'KS')
state =state.str.replace('UTah', 'UT')

dataset = pd.DataFrame({'ID': ID, 'height':height, 'weight':weight, 'City':hometown, 'State':state })
dataset.height = dataset.height.convert_object(convert_numeric=True)
#dataset.to_csv("data/output/dataset.csv", na_rep="NA", index=False)