diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..db1f0d6 Binary files /dev/null and b/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_rename_columns/__pycache__/__init__.cpython-36.pyc b/q01_rename_columns/__pycache__/__init__.cpython-36.pyc index 86045c5..01c10a3 100644 Binary files a/q01_rename_columns/__pycache__/__init__.cpython-36.pyc and b/q01_rename_columns/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_rename_columns/__pycache__/build.cpython-36.pyc b/q01_rename_columns/__pycache__/build.cpython-36.pyc index 56daa0d..9b6ad4c 100644 Binary files a/q01_rename_columns/__pycache__/build.cpython-36.pyc and b/q01_rename_columns/__pycache__/build.cpython-36.pyc differ diff --git a/q01_rename_columns/build.py b/q01_rename_columns/build.py index 5d2373e..9797325 100644 --- a/q01_rename_columns/build.py +++ b/q01_rename_columns/build.py @@ -1,5 +1,33 @@ +# %load q01_rename_columns/build.py # default imports import pandas as pd +path = './data/olympics.csv' +def q01_rename_columns(path): + data=pd.read_csv(path,skiprows=[0]) +# data=pd.DataFrame(data) +# data=data.drop(0) + + data=data.rename(columns={data.columns[0]:'Country'}) + my_list=['Gold_Summer','Silver_Summer','Bronze_Summer','Total_Summer','# Winter','Gold_Winter','Silver_Winter','Bronze_Winter','Total_Winter','# Games','Gold_Total','Silver_Total','Bronze_Total','Total'] + data=data.rename(columns=dict(zip(data.columns[2:],my_list))) + + return data +q01_rename_columns('./data/olympics.csv') + + + + + + + + + + + + + + + diff --git a/q01_rename_columns/tests/__pycache__/__init__.cpython-36.pyc b/q01_rename_columns/tests/__pycache__/__init__.cpython-36.pyc index ee14684..609a673 100644 Binary files a/q01_rename_columns/tests/__pycache__/__init__.cpython-36.pyc and b/q01_rename_columns/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_rename_columns/tests/__pycache__/test.cpython-36.pyc b/q01_rename_columns/tests/__pycache__/test.cpython-36.pyc index bd0596e..2439247 100644 Binary files a/q01_rename_columns/tests/__pycache__/test.cpython-36.pyc and b/q01_rename_columns/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q02_country_operations/__pycache__/__init__.cpython-36.pyc b/q02_country_operations/__pycache__/__init__.cpython-36.pyc index 005bbe0..7dd54c6 100644 Binary files a/q02_country_operations/__pycache__/__init__.cpython-36.pyc and b/q02_country_operations/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_country_operations/__pycache__/build.cpython-36.pyc b/q02_country_operations/__pycache__/build.cpython-36.pyc index 65c7fed..e22efb6 100644 Binary files a/q02_country_operations/__pycache__/build.cpython-36.pyc and b/q02_country_operations/__pycache__/build.cpython-36.pyc differ diff --git a/q02_country_operations/build.py b/q02_country_operations/build.py index d4c641d..9b1af6e 100644 --- a/q02_country_operations/build.py +++ b/q02_country_operations/build.py @@ -1,8 +1,20 @@ +# %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): + OlympicsDF['Country names']=OlympicsDF['Country'].apply(lambda x : (x.split('(')[0]).replace(u'\xa0',u'')) + return OlympicsDF + + +q02_country_operations(OlympicsDF) + + + + diff --git a/q02_country_operations/tests/__pycache__/__init__.cpython-36.pyc b/q02_country_operations/tests/__pycache__/__init__.cpython-36.pyc index 3d1192a..989d8e7 100644 Binary files a/q02_country_operations/tests/__pycache__/__init__.cpython-36.pyc and b/q02_country_operations/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_country_operations/tests/__pycache__/test.cpython-36.pyc b/q02_country_operations/tests/__pycache__/test.cpython-36.pyc index 1d77332..c5e2810 100644 Binary files a/q02_country_operations/tests/__pycache__/test.cpython-36.pyc and b/q02_country_operations/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q03_better_event/__pycache__/__init__.cpython-36.pyc b/q03_better_event/__pycache__/__init__.cpython-36.pyc index a1d4f17..b8a350d 100644 Binary files a/q03_better_event/__pycache__/__init__.cpython-36.pyc and b/q03_better_event/__pycache__/__init__.cpython-36.pyc differ diff --git a/q03_better_event/build.py b/q03_better_event/build.py index 4756f94..6f028c7 100644 --- a/q03_better_event/build.py +++ b/q03_better_event/build.py @@ -1,13 +1,26 @@ +# %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 #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'] = OlympicsDF.apply(f, axis=1) + return OlympicsDF +q03_better_event(OlympicsDF) + + + + + + +| + diff --git a/q03_better_event/tests/__pycache__/__init__.cpython-36.pyc b/q03_better_event/tests/__pycache__/__init__.cpython-36.pyc index 3988395..b158368 100644 Binary files a/q03_better_event/tests/__pycache__/__init__.cpython-36.pyc and b/q03_better_event/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q03_better_event/tests/__pycache__/test.cpython-36.pyc b/q03_better_event/tests/__pycache__/test.cpython-36.pyc index 2b9c3a2..3ae2fe3 100644 Binary files a/q03_better_event/tests/__pycache__/test.cpython-36.pyc and b/q03_better_event/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q04_find_top_10/__pycache__/__init__.cpython-36.pyc b/q04_find_top_10/__pycache__/__init__.cpython-36.pyc index d8fba08..77d3899 100644 Binary files a/q04_find_top_10/__pycache__/__init__.cpython-36.pyc and b/q04_find_top_10/__pycache__/__init__.cpython-36.pyc differ diff --git a/q04_find_top_10/__pycache__/build.cpython-36.pyc b/q04_find_top_10/__pycache__/build.cpython-36.pyc index 0068560..22d11a4 100644 Binary files a/q04_find_top_10/__pycache__/build.cpython-36.pyc and b/q04_find_top_10/__pycache__/build.cpython-36.pyc differ diff --git a/q04_find_top_10/build.py b/q04_find_top_10/build.py index 9f283b7..2c9acc3 100644 --- a/q04_find_top_10/build.py +++ b/q04_find_top_10/build.py @@ -1,8 +1,29 @@ +# %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) +def q04_find_top_10(df ,Sum,Win,Total): + df=df[:146] + list_Sum, list_Win, list_T, Common = [] , [] ,[] , [] + list_Sum = df.nlargest(10,Sum) + + list_Win = df.nlargest(10,Win) + list_T = df.nlargest(10,Total) + com = list(set(list_Sum['Country_Name']).intersection(list_Win['Country_Name'],list_T['Country_Name'])) + + #Common_L =set(Common).intersection(list_T) + + return (list_Sum['Country_Name'].reset_index(drop=True)),(list_Win['Country_Name'].reset_index(drop=True)),(list_T['Country_Name'].reset_index(drop=True)),com + +q04_find_top_10(OlympicsDF,'Total_Summer','Total_Winter','Total') + + + + + + diff --git a/q04_find_top_10/tests/__pycache__/__init__.cpython-36.pyc b/q04_find_top_10/tests/__pycache__/__init__.cpython-36.pyc index b6dea62..16da6f0 100644 Binary files a/q04_find_top_10/tests/__pycache__/__init__.cpython-36.pyc and b/q04_find_top_10/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q04_find_top_10/tests/__pycache__/test.cpython-36.pyc b/q04_find_top_10/tests/__pycache__/test.cpython-36.pyc index f2adc9c..422e0ef 100644 Binary files a/q04_find_top_10/tests/__pycache__/test.cpython-36.pyc and b/q04_find_top_10/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q05_top_10_plotting/__pycache__/__init__.cpython-36.pyc b/q05_top_10_plotting/__pycache__/__init__.cpython-36.pyc index 36afe44..7178fd0 100644 Binary files a/q05_top_10_plotting/__pycache__/__init__.cpython-36.pyc and b/q05_top_10_plotting/__pycache__/__init__.cpython-36.pyc differ diff --git a/q05_top_10_plotting/__pycache__/build.cpython-36.pyc b/q05_top_10_plotting/__pycache__/build.cpython-36.pyc index f75beb5..c71f24e 100644 Binary files a/q05_top_10_plotting/__pycache__/build.cpython-36.pyc and b/q05_top_10_plotting/__pycache__/build.cpython-36.pyc differ diff --git a/q05_top_10_plotting/build.py b/q05_top_10_plotting/build.py index 78064cc..47081d9 100644 --- a/q05_top_10_plotting/build.py +++ b/q05_top_10_plotting/build.py @@ -1,14 +1,38 @@ +# %load q05_top_10_plotting/build.py # default imports import matplotlib.pyplot as plt from greyatomlib.olympics_project_new.q04_find_top_10.build import q04_find_top_10, q03_better_event, q02_country_operations, q01_rename_columns plt.switch_backend('agg') -path = "./data/olympics.csv" +path = './data/olympics.csv' OlympicsDF=q01_rename_columns(path) OlympicsDF=q02_country_operations(OlympicsDF) OlympicsDF=q03_better_event(OlympicsDF) Top10Summer,Top10Winter, Top10, Common =q04_find_top_10(OlympicsDF,'Total_Summer', 'Total_Winter','Total') +def q05_top_10_plotting(OlympicsDF,Top10Summer,Top10Winter, Top10): + + list_Sum = OlympicsDF.nlargest(10,['Total_Summer']) + y=list_Sum['Total_Summer'] + x=Top10Summer + plt.bar(x,y) + + list_Win = OlympicsDF.nlargest(10,['Total_Winter']) + a=list_Win['Total_Winter'] + b=Top10Winter + plt.bar(a,b) + + list_T = OlympicsDF.nlargest(10,['Total']) + y_1=list_T['Total'] + x_1=Top10 + plt.bar(x_1,y_1) + + return + +q05_top_10_plotting(OlympicsDF,Top10Summer,Top10Winter, Top10) + + + diff --git a/q05_top_10_plotting/tests/__pycache__/__init__.cpython-36.pyc b/q05_top_10_plotting/tests/__pycache__/__init__.cpython-36.pyc index 3fdeb4e..b602b71 100644 Binary files a/q05_top_10_plotting/tests/__pycache__/__init__.cpython-36.pyc and b/q05_top_10_plotting/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q05_top_10_plotting/tests/__pycache__/test.cpython-36.pyc b/q05_top_10_plotting/tests/__pycache__/test.cpython-36.pyc index ddca5ec..4015919 100644 Binary files a/q05_top_10_plotting/tests/__pycache__/test.cpython-36.pyc and b/q05_top_10_plotting/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q06_golden_winner/__pycache__/__init__.cpython-36.pyc b/q06_golden_winner/__pycache__/__init__.cpython-36.pyc index 52aa4b0..9a4a937 100644 Binary files a/q06_golden_winner/__pycache__/__init__.cpython-36.pyc and b/q06_golden_winner/__pycache__/__init__.cpython-36.pyc differ diff --git a/q06_golden_winner/__pycache__/build.cpython-36.pyc b/q06_golden_winner/__pycache__/build.cpython-36.pyc index 03a0fd0..541e14c 100644 Binary files a/q06_golden_winner/__pycache__/build.cpython-36.pyc and b/q06_golden_winner/__pycache__/build.cpython-36.pyc differ diff --git a/q06_golden_winner/build.py b/q06_golden_winner/build.py index 4789e29..8f96889 100644 --- a/q06_golden_winner/build.py +++ b/q06_golden_winner/build.py @@ -1,10 +1,28 @@ +# %load q06_golden_winner/build.py # default imports from greyatomlib.olympics_project_new.q04_find_top_10.build import q04_find_top_10, 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) Top10Summer,Top10Winter, Top10, Common =q04_find_top_10(OlympicsDF,'Total_Summer', 'Total_Winter','Total') +def q06_golden_winner(df, Sum, Win, Tot): + Gold_Ratio= [] + + + list_Sum = df.nlargest(10,['Total_Summer']) + list_Win = df.nlargest(10,['Total_Winter']) + list_Tot = df.nlargest(10,['Total']) + Gold_Ratio_1=list(list_Sum.groupby(['Country_Name']).apply(lambda s: s.Gold_Summer/s.Total_Summer).sort_values(ascending = False).head(1).index[0]) + Gold_Ratio_2=list(list_Sum.groupby(['Country_Name']).apply(lambda s: s.Gold_Winter/s.Total_Winter).sort_values(ascending = False).head(1).index[0]) + Gold_Ratio_3=list(list_Sum.groupby(['Country_Name']).apply(lambda s: s.Gold_Total/s.Total).sort_values(ascending = False).head(1).index[0]) + + return Gold_Ratio_1[0],Gold_Ratio_2[0],Gold_Ratio_3[0] + +q06_golden_winner(OlympicsDF,Top10Summer,Top10Winter,Top10) + + + diff --git a/q06_golden_winner/tests/__pycache__/__init__.cpython-36.pyc b/q06_golden_winner/tests/__pycache__/__init__.cpython-36.pyc index 78c9f23..5a9ebed 100644 Binary files a/q06_golden_winner/tests/__pycache__/__init__.cpython-36.pyc and b/q06_golden_winner/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q06_golden_winner/tests/__pycache__/test.cpython-36.pyc b/q06_golden_winner/tests/__pycache__/test.cpython-36.pyc index 8c58d9e..b858650 100644 Binary files a/q06_golden_winner/tests/__pycache__/test.cpython-36.pyc and b/q06_golden_winner/tests/__pycache__/test.cpython-36.pyc differ