diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc index 91557cd..eaf7d59 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..18e7205 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..8080b24 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..cbb9549 100644 --- a/q01_load_data/build.py +++ b/q01_load_data/build.py @@ -1,10 +1,21 @@ +# %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" + '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 +#print(q01_load_data(path)) + diff --git a/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc b/q01_load_data/tests/__pycache__/__init__.cpython-36.pyc index 46496ca..8ea76eb 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..8d5b54b 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..9ad53e3 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..946d132 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..e07d430 100644 --- a/q02_rename_columns/build.py +++ b/q02_rename_columns/build.py @@ -1,9 +1,15 @@ +# %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" + df = q01_load_data(path) - \ No newline at end of file + df.rename(columns={'01 !': 'Gold' , '02 !' : 'Silver', '03 !' : 'Bronze'}, inplace=True) + return df + +#print(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..5148bdc 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..5714d30 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..2bb752e 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..d1d7de7 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..62543d5 100644 --- a/q03_split_country/build.py +++ b/q03_split_country/build.py @@ -1,10 +1,25 @@ +# %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" + 'write your solution here' df = q02_rename_columns(path) - \ No newline at end of file + cname = df.loc[:,'country name'] + + for i in range(1,cname.shape[0]): + cname[i] = cname[i].split('(')[0].rstrip() #Split the characters with '(' and strip the unnecessary characters using rstrip() + + df1 = df.drop(labels='country name',axis=1) + df1.index = cname + df2 = df1.drop(labels='Totals',axis=0) + + return df2 + +#print(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..8662642 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..5acc528 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..d5e9128 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..bfe1171 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..eedcf5b 100644 --- a/q04_country_with_most_gold_medals/build.py +++ b/q04_country_with_most_gold_medals/build.py @@ -1,11 +1,20 @@ +# %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" + 'write your solution here' df = q03_summer_gold_medals(path) + df1 = df.loc[:,'Gold'] + df1.iloc[:,:] = df1.iloc[:,:].apply(pd.to_numeric) + df2 = df1.iloc[:,:].sum(axis=1) + return df2[df2 == df2.max()].index[0] +#print(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..bb5610f 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..562453c 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..b99d12c 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..2356799 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..56f6ecd 100644 --- a/q05_difference_in_gold_medal/build.py +++ b/q05_difference_in_gold_medal/build.py @@ -1,9 +1,22 @@ +# %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): -def q05_difference_in_gold_medal(): - "write your solution here" + df = q02_rename_columns(path) + df1 = df.loc[:,['country name','Gold']] + df2 = df1.iloc[:,[0,1,2]] + df3 = df2.set_index(keys='country name') + df3.loc[:,:] = df3.loc[:,:].apply(pd.to_numeric) + df3.drop(['Totals'],inplace=True) + df4 = df3.iloc[:,0] - df3.iloc[:,1] + df4 = df4.abs() + return df4.max() + + +#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..be5f00f 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..55249cf 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..1f24b6f 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..0c9621b 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..dbbf5c1 100644 --- a/q06_get_points/build.py +++ b/q06_get_points/build.py @@ -1,9 +1,17 @@ +# %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) + df1 = df.loc[:,['country name','Gold','Silver','Bronze']] + df2 = df1.iloc[:,[0,3,6,9]] + df3 = df2 + df3 = df3.loc[:,['Gold','Silver','Bronze']].apply(pd.to_numeric) + df3['Points'] = df3.loc[:,'Gold']*3 + df3.loc[:,'Silver']*2 + df3.loc[:,'Bronze']*1 + df3.drop(labels=['Gold','Silver','Bronze'],axis=1,inplace=True) + return df3['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..06e27e6 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..32a7996 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