diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc index 91557cd..25da6cb 100644 Binary files a/__pycache__/__init__.cpython-36.pyc and b/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_load_data/__pycache__/__init__.cpython-36.pyc b/q01_load_data/__pycache__/__init__.cpython-36.pyc index 5e9e2e2..d06a8e5 100644 Binary files a/q01_load_data/__pycache__/__init__.cpython-36.pyc and b/q01_load_data/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_load_data/__pycache__/build.cpython-36.pyc b/q01_load_data/__pycache__/build.cpython-36.pyc index 6ba929f..d3cc2c2 100644 Binary files a/q01_load_data/__pycache__/build.cpython-36.pyc and b/q01_load_data/__pycache__/build.cpython-36.pyc differ diff --git a/q01_load_data/build.py b/q01_load_data/build.py index 1a26cc1..87da74f 100644 --- a/q01_load_data/build.py +++ b/q01_load_data/build.py @@ -1,10 +1,18 @@ +# %load q01_load_data/build.py import pandas as pd import numpy as np from sklearn.model_selection import train_test_split def q01_load_data(path): - "write your solution here" + 'write your solution here' # use .read_csv function to read the # data and header=0 to skip the first row + df = pd.read_csv(path, header=0) + new_header = df.iloc[0] # grab the first row for the header + new_header[0] = 'country name' + df = df[1:] # take the data less the header row + df.columns = new_header # set the header row as the df header + return df +q01_load_data('./data/olympics.csv') diff --git a/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc b/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc index 46496ca..0dc2ad6 100644 Binary files a/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc and b/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_load_data/tests/__pycache__/test.cpython-36.pyc b/q01_load_data/tests/__pycache__/test.cpython-36.pyc index 0dc2257..20f5cee 100644 Binary files a/q01_load_data/tests/__pycache__/test.cpython-36.pyc and b/q01_load_data/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q02_rename_columns/__pycache__/__init__.cpython-36.pyc b/q02_rename_columns/__pycache__/__init__.cpython-36.pyc index 687491c..1bd4e85 100644 Binary files a/q02_rename_columns/__pycache__/__init__.cpython-36.pyc and b/q02_rename_columns/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_rename_columns/__pycache__/build.cpython-36.pyc b/q02_rename_columns/__pycache__/build.cpython-36.pyc index 28092f5..1466969 100644 Binary files a/q02_rename_columns/__pycache__/build.cpython-36.pyc and b/q02_rename_columns/__pycache__/build.cpython-36.pyc differ diff --git a/q02_rename_columns/build.py b/q02_rename_columns/build.py index 20dd8e9..b0cb90d 100644 --- a/q02_rename_columns/build.py +++ b/q02_rename_columns/build.py @@ -1,9 +1,27 @@ +# %load q02_rename_columns/build.py import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from greyatomlib.olympics_project.q01_load_data.build import q01_load_data def q02_rename_columns(path): - "write your solution here" + 'write your solution here' df = q01_load_data(path) - \ No newline at end of file + #print(df.columns) + colList = list(df.columns) + #df['01 !'] + #print(colList) + for n, i in enumerate(colList): + #print(n) + #print(i) + if '01' in i: + colList[n] = 'Gold' + elif '02' in i: + colList[n] = 'Silver' + elif '03' in i: + colList[n] = 'Bronze' + #print(colList) + df.columns = colList + return df.head(5) +q02_rename_columns('./data/olympics.csv') + diff --git a/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc b/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc index 198a898..a1be0d7 100644 Binary files a/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc and b/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_rename_columns/tests/__pycache__/test.cpython-36.pyc b/q02_rename_columns/tests/__pycache__/test.cpython-36.pyc index 1c28f5b..6c267c7 100644 Binary files a/q02_rename_columns/tests/__pycache__/test.cpython-36.pyc and b/q02_rename_columns/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q03_split_country/__pycache__/__init__.cpython-36.pyc b/q03_split_country/__pycache__/__init__.cpython-36.pyc index e71d6ad..e333370 100644 Binary files a/q03_split_country/__pycache__/__init__.cpython-36.pyc and b/q03_split_country/__pycache__/__init__.cpython-36.pyc differ diff --git a/q03_split_country/__pycache__/build.cpython-36.pyc b/q03_split_country/__pycache__/build.cpython-36.pyc index 5935601..2c6173d 100644 Binary files a/q03_split_country/__pycache__/build.cpython-36.pyc and b/q03_split_country/__pycache__/build.cpython-36.pyc differ diff --git a/q03_split_country/build.py b/q03_split_country/build.py index 6c075fb..b705050 100644 --- a/q03_split_country/build.py +++ b/q03_split_country/build.py @@ -1,3 +1,4 @@ +# %load q03_split_country/build.py import pandas as pd import numpy as np from sklearn.model_selection import train_test_split @@ -5,6 +6,18 @@ def q03_summer_gold_medals(path): - "write your solution here" + 'write your solution here' df = q02_rename_columns(path) - \ No newline at end of file + + df['country name'] = df['country name'].str.split('(',1).apply(lambda x :x[0]) + df.set_index('country name',inplace = True) + df.dropna(inplace = True) + df.drop(['Totals'],axis=0,inplace = True) + print(df.shape) + print(df.columns) + + return df + + +q03_summer_gold_medals('./data/olympics.csv') + diff --git a/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc b/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc index 6015fed..c9e620d 100644 Binary files a/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc and b/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q03_split_country/tests/__pycache__/test.cpython-36.pyc b/q03_split_country/tests/__pycache__/test.cpython-36.pyc index 51cbfae..268840e 100644 Binary files a/q03_split_country/tests/__pycache__/test.cpython-36.pyc and b/q03_split_country/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q04_country_with_most_gold_medals/__pycache__/__init__.cpython-36.pyc b/q04_country_with_most_gold_medals/__pycache__/__init__.cpython-36.pyc index 5be5c53..d6c0e16 100644 Binary files a/q04_country_with_most_gold_medals/__pycache__/__init__.cpython-36.pyc and b/q04_country_with_most_gold_medals/__pycache__/__init__.cpython-36.pyc differ diff --git a/q04_country_with_most_gold_medals/__pycache__/build.cpython-36.pyc b/q04_country_with_most_gold_medals/__pycache__/build.cpython-36.pyc index edf8f75..eb00ee5 100644 Binary files a/q04_country_with_most_gold_medals/__pycache__/build.cpython-36.pyc and b/q04_country_with_most_gold_medals/__pycache__/build.cpython-36.pyc differ diff --git a/q04_country_with_most_gold_medals/build.py b/q04_country_with_most_gold_medals/build.py index 27251ef..1e4b27d 100644 --- a/q04_country_with_most_gold_medals/build.py +++ b/q04_country_with_most_gold_medals/build.py @@ -1,3 +1,4 @@ +# %load q04_country_with_most_gold_medals/build.py import pandas as pd import numpy as np from sklearn.model_selection import train_test_split @@ -5,7 +6,13 @@ def q04_country_with_most_gold_medals(path): - "write your solution here" + 'write your solution here' df = q03_summer_gold_medals(path) - + #print() + goldDF = df['Gold'].iloc[:,-1].astype('int') + countryLargest = goldDF.nlargest(1) + print(countryLargest) + return countryLargest.index[0] + +q04_country_with_most_gold_medals('./data/olympics.csv') diff --git a/q04_country_with_most_gold_medals/tests/__pycache__/__init__.cpython-36.pyc b/q04_country_with_most_gold_medals/tests/__pycache__/__init__.cpython-36.pyc index e7d7d49..74cf39f 100644 Binary files a/q04_country_with_most_gold_medals/tests/__pycache__/__init__.cpython-36.pyc and b/q04_country_with_most_gold_medals/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q04_country_with_most_gold_medals/tests/__pycache__/test.cpython-36.pyc b/q04_country_with_most_gold_medals/tests/__pycache__/test.cpython-36.pyc index b79dc60..552d4b2 100644 Binary files a/q04_country_with_most_gold_medals/tests/__pycache__/test.cpython-36.pyc and b/q04_country_with_most_gold_medals/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q05_difference_in_gold_medal/__pycache__/__init__.cpython-36.pyc b/q05_difference_in_gold_medal/__pycache__/__init__.cpython-36.pyc index 2001848..afe180c 100644 Binary files a/q05_difference_in_gold_medal/__pycache__/__init__.cpython-36.pyc and b/q05_difference_in_gold_medal/__pycache__/__init__.cpython-36.pyc differ diff --git a/q05_difference_in_gold_medal/__pycache__/build.cpython-36.pyc b/q05_difference_in_gold_medal/__pycache__/build.cpython-36.pyc index ff681a3..26c4c06 100644 Binary files a/q05_difference_in_gold_medal/__pycache__/build.cpython-36.pyc and b/q05_difference_in_gold_medal/__pycache__/build.cpython-36.pyc differ diff --git a/q05_difference_in_gold_medal/build.py b/q05_difference_in_gold_medal/build.py index 9fb11ec..1559a6b 100644 --- a/q05_difference_in_gold_medal/build.py +++ b/q05_difference_in_gold_medal/build.py @@ -1,9 +1,19 @@ +# %load q05_difference_in_gold_medal/build.py import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from greyatomlib.olympics_project.q02_rename_columns.build import q02_rename_columns -def q05_difference_in_gold_medal(): - "write your solution here" - +def q05_difference_in_gold_medal(path): + 'write your solution here' + df = q02_rename_columns(path) + df = df.drop([147]) + dfGold = df['Gold'] + print(dfGold.iloc[:,0].astype('int').max()) + print(dfGold.iloc[:,0].astype('int').min()) + diff = dfGold.iloc[:,0].astype('int') - dfGold.iloc[:,1].astype('int') + diffIndex = diff.idxmax() + print(diff.max()) + return diff.max() +q05_difference_in_gold_medal('./data/olympics.csv') diff --git a/q05_difference_in_gold_medal/tests/__pycache__/__init__.cpython-36.pyc b/q05_difference_in_gold_medal/tests/__pycache__/__init__.cpython-36.pyc index 7b04315..d2db12b 100644 Binary files a/q05_difference_in_gold_medal/tests/__pycache__/__init__.cpython-36.pyc and b/q05_difference_in_gold_medal/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q05_difference_in_gold_medal/tests/__pycache__/test.cpython-36.pyc b/q05_difference_in_gold_medal/tests/__pycache__/test.cpython-36.pyc index efd000f..563c948 100644 Binary files a/q05_difference_in_gold_medal/tests/__pycache__/test.cpython-36.pyc and b/q05_difference_in_gold_medal/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q06_get_points/__pycache__/__init__.cpython-36.pyc b/q06_get_points/__pycache__/__init__.cpython-36.pyc index 7c1cf4d..9ff0b85 100644 Binary files a/q06_get_points/__pycache__/__init__.cpython-36.pyc and b/q06_get_points/__pycache__/__init__.cpython-36.pyc differ diff --git a/q06_get_points/__pycache__/build.cpython-36.pyc b/q06_get_points/__pycache__/build.cpython-36.pyc index d45fe38..d0b821f 100644 Binary files a/q06_get_points/__pycache__/build.cpython-36.pyc and b/q06_get_points/__pycache__/build.cpython-36.pyc differ diff --git a/q06_get_points/build.py b/q06_get_points/build.py index 4f4afd7..14503a0 100644 --- a/q06_get_points/build.py +++ b/q06_get_points/build.py @@ -1,9 +1,16 @@ +# %load q06_get_points/build.py import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from greyatomlib.olympics_project.q02_rename_columns.build import q02_rename_columns -path = "data/olympics.csv" +path = 'data/olympics.csv' +def q06_get_points(path): + df = q02_rename_columns(path) + df['Points'] = df['Gold'].iloc[:,-1].astype('int') * 3 + df['Silver'].iloc[:,-1].astype('int') * 2 + df['Bronze'].iloc[:,-1].astype('int') * 1 + return df['Points'] + +q06_get_points(path) diff --git a/q06_get_points/tests/__pycache__/__init__.cpython-36.pyc b/q06_get_points/tests/__pycache__/__init__.cpython-36.pyc index 7db8f24..1c9de38 100644 Binary files a/q06_get_points/tests/__pycache__/__init__.cpython-36.pyc and b/q06_get_points/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q06_get_points/tests/__pycache__/test.cpython-36.pyc b/q06_get_points/tests/__pycache__/test.cpython-36.pyc index 8cccf4a..35c0ea1 100644 Binary files a/q06_get_points/tests/__pycache__/test.cpython-36.pyc and b/q06_get_points/tests/__pycache__/test.cpython-36.pyc differ