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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ Which country had the biggest difference between their summer and winter gold me
Write a function to update the dataframe to include a new column called "Points" for Games which is a weighted value where each gold medal counts for 3 points, silver medals for 2 points, and bronze
medals for 1 point. The function should return only the column (a Series object) which you created.
* Create a function get_points.
* Return dataframe with points column and index.
* Return dataframe with points column and index.
34 changes: 16 additions & 18 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@


def load_data():
"""
Enter your code here
"""

df = pd.read_csv('files/olympics.csv',skiprows=1)
df.rename(columns={'01 !': 'Gold', '02 !': 'Silver','03 !':'Bronze'}, inplace=True)
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
"""
comparison_data = df.iloc[:,[0,5,10]]
comparison_data['Difference'] = comparison_data.iloc[:,1] - comparison_data.iloc[:,2]
return comparison_data.iloc[:,3].idxmax()


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()
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.