Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
Binary file added build.pyc
Binary file not shown.
Binary file added tests/__init__.pyc
Binary file not shown.
Binary file added tests/test_load_data.pyc
Binary file not shown.