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 modified __pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_load_data/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_load_data/__pycache__/build.cpython-36.pyc
Binary file not shown.
14 changes: 9 additions & 5 deletions q01_load_data/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#%load q01_load_data/build.py
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split


path ='./data/olympics.csv'
def q01_load_data(path):
"write your solution here"
# use .read_csv function to read the
# data and header=0 to skip the first row
data = pd.read_csv(path)
data_header = data.iloc[0]
data=data[1:]
data_header[0]='country name'
data.columns=data_header
return data


Binary file modified q01_load_data/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_load_data/tests/__pycache__/test.cpython-36.pyc
Binary file not shown.
Binary file modified q02_rename_columns/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q02_rename_columns/__pycache__/build.cpython-36.pyc
Binary file not shown.
17 changes: 15 additions & 2 deletions q02_rename_columns/build.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# %load q02_rename_columns/build.py
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from greyatomlib.olympics_project.q01_load_data.build import q01_load_data

path= './data/olympics.csv'
def q02_rename_columns(path):
"write your solution here"
'write your solution here'
df = q01_load_data(path)

data_header = list(df.columns.values)
for i in range(0,len(data_header),1):
if(str(data_header[i])=='01 !'):
data_header[i]='Gold'
if(str(data_header[i])=='02 !'):
data_header[i]='Silver'
if(str(data_header[i])=='03 !'):
data_header[i]='Bronze'
df=df[1:]
df.columns=data_header
return df

Binary file modified q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q02_rename_columns/tests/__pycache__/test.cpython-36.pyc
Binary file not shown.
Binary file modified q03_split_country/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q03_split_country/__pycache__/build.cpython-36.pyc
Binary file not shown.
17 changes: 13 additions & 4 deletions q03_split_country/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# %load q03_split_country/build.py
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from greyatomlib.olympics_project.q02_rename_columns.build import q02_rename_columns


path='./data/olympics.csv'
def q03_summer_gold_medals(path):
"write your solution here"
df = q02_rename_columns(path)

'write your solution here'
df2 = q02_rename_columns(path)
df2. rename(columns={'country name': 'country_name'}, inplace=True)
df2['country name'] = df2['country_name'].str.split('(', 1).str.get(0)
df2.set_index('country name', inplace=True)
df2 = df2.drop('country_name', 1)
df2 = df2.drop('Totals', 0)
return df2



Binary file modified q03_split_country/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q03_split_country/tests/__pycache__/test.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file modified q04_country_with_most_gold_medals/__pycache__/build.cpython-36.pyc
Binary file not shown.
27 changes: 24 additions & 3 deletions q04_country_with_most_gold_medals/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
# %load q04_country_with_most_gold_medals/build.py
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from greyatomlib.olympics_project.q03_split_country.build import q03_summer_gold_medals

path='./data/olympics.csv'

def q04_country_with_most_gold_medals(path):
"write your solution here"
df = q03_summer_gold_medals(path)
'write your solution here'
data = q03_summer_gold_medals(path)
x,y=data.shape
list1=[]
for j in range(0,x,1):
sum1=0
for i in range(0,len(data.columns),1):
if str(data.columns[i])=='Gold':
sum1+=int(data.iloc[j,i])

list1.append(sum1)

max_val=max(list1)
max_index=list1.index(max_val)
data= data.reset_index()

max_country=data.iloc[max_index,0]



return max_country



Binary file not shown.
Binary file not shown.