diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..3c2dd12 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..3fcb1e4 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..cea367b 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..c91b9de 100644 --- a/q01_rename_columns/build.py +++ b/q01_rename_columns/build.py @@ -1,5 +1,12 @@ +# %load q01_rename_columns/build.py # default imports import pandas as pd +path='./data/olympics.csv' +def q01_rename_columns(path): + oly_df=pd.read_csv(path,skiprows=1,delimiter=',') + oly_df.rename(columns={'Unnamed: 0':'Country','01 !':'Gold_Summer','01 !.1':'Gold_Winter','02 !':'Silver_Summer','02 !.1':'Silver_Winter','03 !': 'Bronze_Summer','03 !.1':'Bronze_Winter','Total':'Total_Summer','Total.1':'Total_Winter','01 !.2':'Gold_Total','02 !.2':'Silver_Total','03 !.2':'Bronze_Total','Combined total':'Total'},inplace=True) + return oly_df + diff --git a/q01_rename_columns/tests/__pycache__/__init__.cpython-36.pyc b/q01_rename_columns/tests/__pycache__/__init__.cpython-36.pyc index ee14684..cfd1d5c 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..5a96440 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..450a380 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..7285707 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..dbbdcc7 100644 --- a/q02_country_operations/build.py +++ b/q02_country_operations/build.py @@ -1,10 +1,12 @@ +# %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_Name']=(OlympicsDF['Country'].str.split('(').str)[0].str.strip() + return(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..5beac75 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..23d978b 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..48bae65 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/__pycache__/build.cpython-36.pyc b/q03_better_event/__pycache__/build.cpython-36.pyc index 98a743b..fae6fff 100644 Binary files a/q03_better_event/__pycache__/build.cpython-36.pyc and b/q03_better_event/__pycache__/build.cpython-36.pyc differ diff --git a/q03_better_event/build.py b/q03_better_event/build.py index 4756f94..1450ff0 100644 --- a/q03_better_event/build.py +++ b/q03_better_event/build.py @@ -1,11 +1,16 @@ +# %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']=np.where(OlympicsDF['Total_Summer']>OlympicsDF['Total_Winter'],'Summer',np.where(OlympicsDF['Total_Summer']==OlympicsDF['Total_Winter'],'Both','Winter')) + return 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..28d53e2 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..4638196 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..b927002 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..74c0a6f 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..e72fa71 100644 --- a/q04_find_top_10/build.py +++ b/q04_find_top_10/build.py @@ -1,8 +1,19 @@ +# %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=OlympicsDF,v1='Total_Summer',v2='Total_Winter',v3='Total'): + top_10_summer=list(df.sort_values(v1,ascending=False)['Country_Name'][1:11]) + top_10_winter=list(df.sort_values(v2,ascending=False)['Country_Name'][1:11]) + top_10_overall=list(df.sort_values(v3,ascending=False)['Country_Name'][1:11]) + common_overall=list(set(top_10_summer).intersection(set(top_10_winter).intersection(set(top_10_overall)))) + return top_10_summer,top_10_winter,top_10_overall,common_overall + + + + 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..9f38161 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..14f215b 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..0c6f059 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..e5200ae 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..391c2c6 100644 --- a/q05_top_10_plotting/build.py +++ b/q05_top_10_plotting/build.py @@ -1,14 +1,36 @@ +# %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): + SOly=OlympicsDF[OlympicsDF['Country_Name'].isin(Top10Summer)] + WOly=OlympicsDF[OlympicsDF['Country_Name'].isin(Top10Winter)] + OOly=OlympicsDF[OlympicsDF['Country_Name'].isin(Top10)] + plt.subplot(2,2,1) + plt.bar(SOly['Country_Name'],SOly['Total_Summer'],color='orange', label='Top 10 Summer') + plt.xlabel('Countries') + plt.ylabel('Total Medals') + plt.title('Top 10 Summer') + plt.subplot(2,2,2) + plt.bar(WOly['Country_Name'],WOly['Total_Winter'],color='cyan', label='Top 10 Winter') + plt.xlabel('Countries') + plt.ylabel('Total Medals') + plt.title('Top 10 Winter') + plt.subplot(2,2,3) + plt.bar(OOly['Country_Name'],OOly['Total'],color='green', label='Top 10 Overall') + plt.xlabel('Countries') + plt.ylabel('Total Medals') + plt.title('Top 10 Overall') + plt.tight_layout(h_pad=1,w_pad=1,pad=1) + plt.show() 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..54b36c8 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..6db021b 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..4db623e 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..b82f3d0 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..2ef6ad9 100644 --- a/q06_golden_winner/build.py +++ b/q06_golden_winner/build.py @@ -1,10 +1,26 @@ +# %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' +import numpy as np 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(OlympicsDF,Top10Summer,Top10Winter,Top10): + SOly=OlympicsDF[OlympicsDF['Country_Name'].isin(Top10Summer)] + WOly=OlympicsDF[OlympicsDF['Country_Name'].isin(Top10Winter)] + OOly=OlympicsDF[OlympicsDF['Country_Name'].isin(Top10)] + Gold_Ratio_Summer=list(SOly['Gold_Summer']/SOly['Total_Summer']) + summer_winner=SOly.iloc[np.argmax(Gold_Ratio_Summer),16] + Gold_Ratio_Winter=list(WOly['Gold_Winter']/WOly['Total_Winter']) + winter_winner=WOly.iloc[np.argmax(Gold_Ratio_Winter),16] + Gold_Ratio_Total=list(OOly['Gold_Total']/OOly['Total']) + total_winner=OOly.iloc[np.argmax(Gold_Ratio_Total),16] + return summer_winner, winter_winner, total_winner + + + diff --git a/q06_golden_winner/tests/__pycache__/__init__.cpython-36.pyc b/q06_golden_winner/tests/__pycache__/__init__.cpython-36.pyc index 78c9f23..77c6bff 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..4fa5783 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 diff --git a/q07_unusual_performances/__pycache__/__init__.cpython-36.pyc b/q07_unusual_performances/__pycache__/__init__.cpython-36.pyc index 288c374..b3d1743 100644 Binary files a/q07_unusual_performances/__pycache__/__init__.cpython-36.pyc and b/q07_unusual_performances/__pycache__/__init__.cpython-36.pyc differ diff --git a/q07_unusual_performances/__pycache__/build.cpython-36.pyc b/q07_unusual_performances/__pycache__/build.cpython-36.pyc index b5f4425..c019019 100644 Binary files a/q07_unusual_performances/__pycache__/build.cpython-36.pyc and b/q07_unusual_performances/__pycache__/build.cpython-36.pyc differ diff --git a/q07_unusual_performances/build.py b/q07_unusual_performances/build.py index a264d21..da9e7e8 100644 --- a/q07_unusual_performances/build.py +++ b/q07_unusual_performances/build.py @@ -1,5 +1,19 @@ +# %load q07_unusual_performances/build.py # default imports from greyatomlib.olympics_project_new.q02_country_operations.build import q02_country_operations, q01_rename_columns -path = "./data/olympics.csv" +path = './data/olympics.csv' +import numpy as np OlympicsDF=q01_rename_columns(path) OlympicsDF=q02_country_operations(OlympicsDF) +def q07_unusual_performances(df=OlympicsDF,high=0.95,low=0.05): + q1=df['Total'].quantile(low) + q2=df['Total'].quantile(high) + df=df[df['Country']!='Totals'] + lowcons=list(df[df['Total']<=q1]['Country_Name']) + highcons=list(df[df['Total']>q2]['Country_Name']) + return lowcons,highcons + + + + + diff --git a/q07_unusual_performances/tests/__pycache__/__init__.cpython-36.pyc b/q07_unusual_performances/tests/__pycache__/__init__.cpython-36.pyc index eea34b6..1cd3f24 100644 Binary files a/q07_unusual_performances/tests/__pycache__/__init__.cpython-36.pyc and b/q07_unusual_performances/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q07_unusual_performances/tests/__pycache__/test.cpython-36.pyc b/q07_unusual_performances/tests/__pycache__/test.cpython-36.pyc index 44dbdd5..41b5024 100644 Binary files a/q07_unusual_performances/tests/__pycache__/test.cpython-36.pyc and b/q07_unusual_performances/tests/__pycache__/test.cpython-36.pyc differ