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
Binary file added __pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_rename_columns/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_rename_columns/__pycache__/build.cpython-36.pyc
Binary file not shown.
17 changes: 17 additions & 0 deletions q01_rename_columns/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# %load q01_rename_columns/build.py
# default imports
import pandas as pd

def q01_rename_columns(path = './data/olympics.csv'):
data = pd.read_csv(path, skiprows=1)
data.rename(columns = {'Unnamed: 0' : 'Country',
'Total':'Total_Summer',
'Total.1':'Total_Winter',
'Combined total':'Total',
'01 !':'Gold_Summer',
'02 !':'Silver_Summer',
'03 !':'Bronze_Summer',
'01 !.1':'Gold_Winter',
'02 !.1':'Silver_Winter',
'03 !.1':'Bronze_Winter',
'01 !.2':'Gold_Total',
'02 !.2':'Silver_Total',
'03 !.2':'Bronze_Total'}, inplace = True)
return data


Binary file modified q01_rename_columns/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_rename_columns/tests/__pycache__/test.cpython-36.pyc
Binary file not shown.
Binary file modified q02_country_operations/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q02_country_operations/__pycache__/build.cpython-36.pyc
Binary file not shown.
9 changes: 7 additions & 2 deletions q02_country_operations/build.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# %load q02_country_operations/build.py
# default imports
from greyatomlib.olympics_project_new.q01_rename_columns.build import q01_rename_columns
#Previous Functions
path = "./data/olympics.csv"
OlympicsDF=q01_rename_columns(path)
path = './data/olympics.csv'
OlympicsDF=q01_rename_columns(path)

def q02_country_operations(OlympicsDF):
country_col_new = OlympicsDF.Country.str.split(expand=True)[0]
OlympicsDF['Country_Name'] = country_col_new
return OlympicsDF



Expand Down
Binary file modified q02_country_operations/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q02_country_operations/tests/__pycache__/test.cpython-36.pyc
Binary file not shown.
Binary file modified q03_better_event/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q03_better_event/__pycache__/build.cpython-36.pyc
Binary file not shown.
16 changes: 14 additions & 2 deletions q03_better_event/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# %load q03_better_event/build.py
#default imports
from greyatomlib.olympics_project_new.q02_country_operations.build import q02_country_operations, q01_rename_columns
import numpy as np
import pandas as pd
#Previous function
path = "./data/olympics.csv"
path = './data/olympics.csv'
OlympicsDF=q01_rename_columns(path)
OlympicsDF=q02_country_operations(OlympicsDF)

def q03_better_event(OlympicsDF=OlympicsDF):
BetterEvent_col = []
for i, j in zip(OlympicsDF['Total_Summer'], OlympicsDF['Total_Winter']):
if i > j:
BetterEvent_col.append('Summer')
elif i < j:
BetterEvent_col.append('Winter')
else:
BetterEvent_col.append('Both')


OlympicsDF['BetterEvent'] = BetterEvent_col
return OlympicsDF



Binary file modified q03_better_event/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q03_better_event/tests/__pycache__/test.cpython-36.pyc
Binary file not shown.
Binary file modified q04_find_top_10/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q04_find_top_10/__pycache__/build.cpython-36.pyc
Binary file not shown.
29 changes: 28 additions & 1 deletion q04_find_top_10/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
# %load q04_find_top_10/build.py
# default imports
from greyatomlib.olympics_project_new.q03_better_event.build import q03_better_event,q02_country_operations, q01_rename_columns
path = "./data/olympics.csv"
path = './data/olympics.csv'

OlympicsDF=q01_rename_columns(path)
OlympicsDF=q02_country_operations(OlympicsDF)
OlympicsDF=q03_better_event(OlympicsDF)

Total_Summer_col = 'Total_Summer'
Total_Winter_col = 'Total_Winter'
Total_col = 'Total'


def q04_find_top_10(OlympicsDF=OlympicsDF, Total_Summer_col = Total_Summer_col, Total_Winter_col = Total_Winter_col, Total_col = Total_col):
ascending_country_names = OlympicsDF.sort_values(by=['Country_Name'], ascending=True)

descending_total_summer = ascending_country_names.sort_values(by=['Total_Summer'], ascending=False)
descending_total_winter = ascending_country_names.sort_values(by=['Total_Winter'], ascending=False)
descending_total = ascending_country_names.sort_values(by=['Total'], ascending=False)

top_10_summer = []
top_10_winter = []
top_10_total = []
count = 1
while (count<=10):
top_10_summer.append(OlympicsDF.iloc[descending_total_summer.index[count],16])
top_10_winter.append(OlympicsDF.iloc[descending_total_winter.index[count],16])
top_10_total.append(OlympicsDF.iloc[descending_total.index[count],16])
count = count + 1
common_countries = list(set(top_10_summer).intersection(set(top_10_winter).intersection(top_10_total)))
return top_10_summer, top_10_winter, top_10_total, common_countries



Binary file modified q04_find_top_10/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q04_find_top_10/tests/__pycache__/test.cpython-36.pyc
Binary file not shown.