diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc index 91557cd..78ec108 100644 Binary files a/__pycache__/__init__.cpython-36.pyc and b/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_rename_columns/__pycache__/__init__.cpython-36.pyc b/q02_rename_columns/__pycache__/__init__.cpython-36.pyc index 687491c..9817313 100644 Binary files a/q02_rename_columns/__pycache__/__init__.cpython-36.pyc and b/q02_rename_columns/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_rename_columns/__pycache__/build.cpython-36.pyc b/q02_rename_columns/__pycache__/build.cpython-36.pyc index 28092f5..ad6e578 100644 Binary files a/q02_rename_columns/__pycache__/build.cpython-36.pyc and b/q02_rename_columns/__pycache__/build.cpython-36.pyc differ diff --git a/q02_rename_columns/build.py b/q02_rename_columns/build.py index 20dd8e9..29bd18c 100644 --- a/q02_rename_columns/build.py +++ b/q02_rename_columns/build.py @@ -1,9 +1,17 @@ +# %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 def q02_rename_columns(path): - "write your solution here" + 'write your solution here' df = q01_load_data(path) - \ No newline at end of file + df = pd.DataFrame(df) + df.rename(columns={'01 !': 'Gold' , '02 !': 'Silver','03 !': 'Bronze'}, inplace=True) + return df + +q02_rename_columns('./data/olympics.csv') + + + diff --git a/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc b/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc index 198a898..465b5de 100644 Binary files a/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc and b/q02_rename_columns/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_rename_columns/tests/__pycache__/test.cpython-36.pyc b/q02_rename_columns/tests/__pycache__/test.cpython-36.pyc index 1c28f5b..8edfdc2 100644 Binary files a/q02_rename_columns/tests/__pycache__/test.cpython-36.pyc and b/q02_rename_columns/tests/__pycache__/test.cpython-36.pyc differ diff --git a/q03_split_country/__pycache__/__init__.cpython-36.pyc b/q03_split_country/__pycache__/__init__.cpython-36.pyc index e71d6ad..dc1b83d 100644 Binary files a/q03_split_country/__pycache__/__init__.cpython-36.pyc and b/q03_split_country/__pycache__/__init__.cpython-36.pyc differ diff --git a/q03_split_country/__pycache__/build.cpython-36.pyc b/q03_split_country/__pycache__/build.cpython-36.pyc index 5935601..157e392 100644 Binary files a/q03_split_country/__pycache__/build.cpython-36.pyc and b/q03_split_country/__pycache__/build.cpython-36.pyc differ diff --git a/q03_split_country/build.py b/q03_split_country/build.py index 6c075fb..a77ce8d 100644 --- a/q03_split_country/build.py +++ b/q03_split_country/build.py @@ -1,10 +1,45 @@ +# %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 +import re +path = './data/olympics.csv' +df_new = [] def q03_summer_gold_medals(path): - "write your solution here" + 'write your solution here' df = q02_rename_columns(path) - \ No newline at end of file + #df = pd.DataFrame(df, index = 'country') + + country = [] + code = [] + + for name in df['country name']: + country.append((name.split()[0])) + code.append(''.join(re.findall('\(\w{3}\)', name))) + + df.index = country + df.drop(labels = ['Combined total'], axis = 1, inplace = True) + df.drop(labels = ['Totals'], axis = 0, inplace = True) + #for name in df['country name']: + # country.append((name.split()[0], ''.join(re.findall('\(\w{3}\)', name)))) + #for i in range(1,lene.(df)+1): + return df + + #df_new.append(df.loc[i,'country name'].split()) + #country = df.loc[i, 'country name'].split() + #print(df.loc[i, 'country name'].str.contains('\(\w{3}\)')) + + + + + + + + + + + + diff --git a/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc b/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc index 6015fed..88b5bf4 100644 Binary files a/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc and b/q03_split_country/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q03_split_country/tests/__pycache__/test.cpython-36.pyc b/q03_split_country/tests/__pycache__/test.cpython-36.pyc index 51cbfae..e613035 100644 Binary files a/q03_split_country/tests/__pycache__/test.cpython-36.pyc and b/q03_split_country/tests/__pycache__/test.cpython-36.pyc differ