diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc index 91557cd..bdeb7c0 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..c3b5da0 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..71d7178 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..4c16689 100644 --- a/q01_load_data/build.py +++ b/q01_load_data/build.py @@ -1,10 +1,22 @@ +# %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) +# print(df) + new_header = df.iloc[0] # grab the first row for the header +# print(new_header) + new_header[0] = 'country name' +# print(new_header) + 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..bd60bdd 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..eeebf5c 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..b034213 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..062f6fb 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..870eac1 100644 --- a/q02_rename_columns/build.py +++ b/q02_rename_columns/build.py @@ -1,9 +1,17 @@ +# %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 + colList = list(df.columns) +# print(colList) +# df = df.rename(columns=lambda ,inplace = True) + 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..e19d40a 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..4b85799 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..42bddaf 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..66e7a87 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..667d1fe 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 + count = df['country name'].str.split('(') +# print(count) + val = count.apply(lambda x :x[0]) +# return val + df['country name'] = val + df.set_index('country name',inplace = True) + df.dropna(inplace = True) + df.drop(['Totals'],axis=0,inplace = True) + 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..9ea82b2 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..99e34de 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..d21fe9c 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..6c27aa0 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..9f02300 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,16 @@ def q04_country_with_most_gold_medals(path): - "write your solution here" + 'write your solution here' df = q03_summer_gold_medals(path) + golddata = df['Gold'].iloc[:,2].astype('int') + coun = golddata.nlargest(1) + country = coun.index[0] + print(country) + print(type(country)) + return country +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..dabc745 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..110dbe9 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