diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc index 91557cd..4989df9 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..d4a5bdc 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..154e6e5 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..abc01cc 100644 --- a/q01_load_data/build.py +++ b/q01_load_data/build.py @@ -1,10 +1,14 @@ 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] + new_header[0] = 'country name' + df = df[1:] + df.columns = new_header + return df + +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..d41e0cc 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..4b8c0a2 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..36a88c7 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..1543de3 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..29d7538 100644 --- a/q02_rename_columns/build.py +++ b/q02_rename_columns/build.py @@ -1,9 +1,11 @@ import pandas as pd -import numpy as np -from sklearn.model_selection import train_test_split +import numpy 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 = df.rename(columns={'01 !': 'Gold', '02 !':'Silver', '03 !':'Bronze'}) + 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..5e1c53a 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..6e8a2a2 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..3e5a348 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..382557d 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..053e3b3 100644 --- a/q03_split_country/build.py +++ b/q03_split_country/build.py @@ -1,10 +1,15 @@ 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 + country_names =[x.split('(')[0] for x in df.iloc[:,0]] + df.set_index(pd.Series(country_names),inplace=True) + df.drop(['country name'], axis = 1, inplace = True) + df.drop(['Totals'], axis = 0, inplace = True) + return df + +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..186d7bb 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..04800eb 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..9383ed5 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..a149c49 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..3b8c42d 100644 --- a/q04_country_with_most_gold_medals/build.py +++ b/q04_country_with_most_gold_medals/build.py @@ -1,11 +1,17 @@ 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 - +from greyatomlib.olympics_project.q02_rename_columns.build import q02_rename_columns +path = './data/olympics.csv' def q04_country_with_most_gold_medals(path): - "write your solution here" - df = q03_summer_gold_medals(path) - + df = q02_rename_columns(path) + country_names =[x.split('(')[0] for x in df.iloc[:,0]] + df.set_index(pd.Series(country_names),inplace=True) + #df.drop(['country name'], axis = 1, inplace = True) + df.drop(['Totals'], axis = 0, inplace = True) + max_gold_list = df.groupby(['country name'])['Gold'].sum() + df2 = max_gold_list.groupby(['country name']).sum() + return df2.idxmax() + +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..ca69345 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..54a39cc 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..95f19cc 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..83eaff8 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..cd4c860 100644 --- a/q05_difference_in_gold_medal/build.py +++ b/q05_difference_in_gold_medal/build.py @@ -1,9 +1,17 @@ -import pandas as pd import numpy as np -from sklearn.model_selection import train_test_split +import pandas as pd from greyatomlib.olympics_project.q02_rename_columns.build import q02_rename_columns -def q05_difference_in_gold_medal(): - "write your solution here" - +path='./data/olympics.csv' +def q05_difference_in_gold_medal(path): + df=q02_rename_columns(path) + country_names =[x.split('(')[0] for x in df.iloc[:,0]] + df.set_index(pd.Series(country_names),inplace=True) + df.drop(['country name'], axis = 1, inplace = True) + df.drop(['Totals'], axis = 0, inplace = True) + diff = (df.iloc[:,1].astype(int) - df.iloc[:,6].astype(int)) + return diff.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..fb73a5f 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..7b9d391 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..192b46e 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..576eff2 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..8ffd2d9 100644 --- a/q06_get_points/build.py +++ b/q06_get_points/build.py @@ -1,9 +1,17 @@ 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) + wt = [3,2,1] + df1 = df.iloc[:,[12,13,14]].astype(int) + res = df1.mul(wt) + df['Points'] = res.sum(axis=1) + return res.sum(axis=1) + +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..2ef95f1 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..1fe1714 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