diff --git a/__init__.pyc b/__init__.pyc index e82d47a..90b1501 100644 Binary files a/__init__.pyc and b/__init__.pyc differ diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc index 91557cd..79c75b7 100644 Binary files a/__pycache__/__init__.cpython-36.pyc and b/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_load_data/__init__.pyc b/q01_load_data/__init__.pyc index d9c451b..6013241 100644 Binary files a/q01_load_data/__init__.pyc and b/q01_load_data/__init__.pyc differ diff --git a/q01_load_data/__pycache__/__init__.cpython-36.pyc b/q01_load_data/__pycache__/__init__.cpython-36.pyc index 5e9e2e2..a2b3bbe 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..348b18c 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 e454f56..fe1e327 100644 --- a/q01_load_data/build.py +++ b/q01_load_data/build.py @@ -1,15 +1,14 @@ +# %load q01_load_data/build.py import pandas as pd import numpy as np from sklearn.model_selection import train_test_split - - +path = './data/olympics.csv' def q01_load_data(path): - "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(path) + diff --git a/q01_load_data/build.pyc b/q01_load_data/build.pyc index 5d838f8..0142c38 100644 Binary files a/q01_load_data/build.pyc and b/q01_load_data/build.pyc differ diff --git a/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc b/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc index 46496ca..fbfb8a0 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..d86139b 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..5c09109 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..aa2d575 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..dcfd442 100644 --- a/q02_rename_columns/build.py +++ b/q02_rename_columns/build.py @@ -1,9 +1,13 @@ +# %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 - +path = './data/olympics.csv' def q02_rename_columns(path): - "write your solution here" + 'write your solution here' df = q01_load_data(path) - \ No newline at end of file + df.rename(columns={'01 !':'Gold','02 !':'Silver','03 !':'Bronze'}, inplace=True) + return df +q02_rename_columns(path) + diff --git a/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc b/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc index 198a898..989a3d2 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..ee3876e 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..b6b6986 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..c117541 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..0a41d0e 100644 --- a/q03_split_country/build.py +++ b/q03_split_country/build.py @@ -1,10 +1,15 @@ +# %load q03_split_country/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' def q03_summer_gold_medals(path): - "write your solution here" df = q02_rename_columns(path) - \ No newline at end of file + df['country name'], df['country_code'] = df['country name'].str.split('(',1).str + df.set_index('country name', inplace=True) + df.drop(labels=['Combined total'], axis=1, inplace=True) + return df[0:146] +q03_summer_gold_medals(path) + diff --git a/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc b/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc index 6015fed..5183e7b 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..4c67177 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..8d42d20 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..3293f73 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..aeeb63e 100644 --- a/q04_country_with_most_gold_medals/build.py +++ b/q04_country_with_most_gold_medals/build.py @@ -1,11 +1,21 @@ +# %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 from greyatomlib.olympics_project.q03_split_country.build import q03_summer_gold_medals - +path = './data/olympics.csv' def q04_country_with_most_gold_medals(path): - "write your solution here" df = q03_summer_gold_medals(path) + df_gold_count = df.iloc[:,[1,6,11]] + df_gold_count = df_gold_count.astype('int') + df_gold_count['Total'] = df_gold_count.sum(axis=1) + df_gold_final = df_gold_count.iloc[:,-1].reset_index() + df_gold_final = df_gold_final[df_gold_final['Total'] == df_gold_final.Total.max()] + return df_gold_final.iloc[0,0] +q04_country_with_most_gold_medals(path) + + + 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..1af2041 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..298e742 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..acf6d98 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..51e502a 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 7891d44..401997b 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 - +path = './data/olympics.csv' def q05_difference_in_gold_medal(path): - "write your solution here" - + df = q02_rename_columns(path) + df_gold_medals = df.iloc[:,[0,2,7]] + df_gold_medals_new = df_gold_medals.iloc[:,[1,2]].astype(int) + df_gold_medals.drop(labels=['Gold'],axis=1, inplace=True) + df_gold_medals_new = pd.concat([df_gold_medals_new, df_gold_medals], axis=1) + df_gold_medals_new['Difference'] = df_gold_medals_new.iloc[:,0] - df_gold_medals_new.iloc[:,1] + df_gold_final = df_gold_medals_new.iloc[:,[2,3]][0:146] + return df_gold_final[df_gold_final['Difference'] == df_gold_final['Difference'].max()].iloc[0,1] + +q05_difference_in_gold_medal(path) + 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..b070b21 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..fd2f4ff 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..d9f11b3 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..6119c57 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 cfd524d..cded826 100644 --- a/q06_get_points/build.py +++ b/q06_get_points/build.py @@ -1,10 +1,19 @@ +# %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' def q06_get_points(path): - "write your solution here" df = q02_rename_columns(path) - + df_gsb = df.iloc[:,[2,3,4,7,8,9,12,13,14]] + df_gsb = df_gsb.astype('int') + df_gsb['Total_Gold'] = df_gsb.iloc[:,0] + df_gsb.iloc[:,3] + df_gsb.iloc[:,6] + df_gsb['Total_Silver'] = df_gsb.iloc[:,1] + df_gsb.iloc[:,4] + df_gsb.iloc[:,7] + df_gsb['Total_Bronze'] = df_gsb.iloc[:,2] + df_gsb.iloc[:,5] + df_gsb.iloc[:,8] + df_gsb['Points'] = df_gsb['Total_Gold']*3 + df_gsb['Total_Silver']*2 + df_gsb['Total_Bronze']*1 + + return (df_gsb['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..9e3889e 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..d4b794a 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