diff --git a/build.py b/build.py index 7df5951..72e2d41 100644 --- a/build.py +++ b/build.py @@ -5,30 +5,48 @@ def load_data(): """ Enter your code here """ + df = pd.read_csv('files/olympics.csv',skiprows = 1) + for column in df.columns: + if '01' in column: + df.rename(inplace=True, columns = {column:column.replace("01 !","Gold")}) + elif '02' in column: + df.rename(inplace=True, columns = {column:column.replace("02 !","Silver")}) + elif '03'in column: + df.rename(inplace=True, columns = {column:column.replace("03 !","Bronze")}) + else: + pass + country_names = [x.split('\xc2\xa0(')[0] for x in df.iloc[:,0]] + df.set_index(pd.Series(country_names), inplace=True) + df.rename(columns={"Unnamed: 0" : "Country"},inplace = True) + df.iloc[:,0] = country_names + df.drop(['Totals'],axis=0, inplace= True) + return df + def first_country(df): """ Enter your code here """ - + return df.iloc[0,:] def gold_medal(df): """ Enter your code here """ - + return df['Gold'].argmax() def biggest_difference_in_gold_medal(df): """ Enter your code here """ - + return (df['Gold']-df['Gold.1']).argmax() def get_points(df): """ Enter your code here """ - + df['Points'] = 3*df.iloc[:,12] + 2*df.iloc[:,13] + df.iloc[:,14] + return df.loc[:,'Points'] # df = load_data() # print(first_country(df)["# Summer"]) diff --git a/build.pyc b/build.pyc new file mode 100644 index 0000000..e066275 Binary files /dev/null and b/build.pyc differ diff --git a/tests/__init__.pyc b/tests/__init__.pyc new file mode 100644 index 0000000..0550111 Binary files /dev/null and b/tests/__init__.pyc differ diff --git a/tests/test_load_data.pyc b/tests/test_load_data.pyc new file mode 100644 index 0000000..d541788 Binary files /dev/null and b/tests/test_load_data.pyc differ