From dcf73e0f55dd78fd5d435978e63d8b0e8b76eab9 Mon Sep 17 00:00:00 2001 From: Vijay1306 Date: Sun, 24 Dec 2017 15:08:38 +0000 Subject: [PATCH 1/7] Done --- q01_zeros_array/build.py | 6 ++++-- q02_zeros_reshaped/build.py | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..01c2b57 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,10 @@ +# %load q01_zeros_array/build.py # Default Imports import sys, os sys.path.append(os.path.join(os.path.dirname(os.curdir), '..' )) import numpy as np # Your solution - - +def array_zeros(): + zeros_array=np.zeros((3,4,2)) + return zeros_array diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..452aab8 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,11 @@ +# %load q02_zeros_reshaped/build.py # Default imports import numpy as np from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros # Write your code +initial_array = array_zeros() + +def array_reshaped_zeros(): + zeros_array_reshaped = initial_array.reshape(2,3,4) + return zeros_array_reshaped From fa927588a8f72630835281fdf78f42a03a3a4007 Mon Sep 17 00:00:00 2001 From: Vijay1306 Date: Sun, 24 Dec 2017 15:44:43 +0000 Subject: [PATCH 2/7] Done --- q03_create_3d_array/build.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..989a252 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,7 @@ # Default Imports import numpy as np -# Enter solution here \ No newline at end of file +# Enter solution here + +def create_3d_array(): + return np.arange(27).reshape(3,3,3) From 2396a462ab91059aeedc6b7febd65dc5cc984d76 Mon Sep 17 00:00:00 2001 From: Vijay1306 Date: Sun, 24 Dec 2017 16:29:06 +0000 Subject: [PATCH 3/7] Done --- q04_read_csv_data_to_ndarray/build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index fb71e6e..d978100 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -2,4 +2,8 @@ import numpy as np path = "./data/ipl_matches_small.csv" -# Enter code here \ No newline at end of file +# Enter code here + +def read_csv_data_to_ndarray(path, input_dtype): + iplarray = np.genfromtxt(path,input_dtype, delimiter=',', skip_header = 1) + return iplarray From b07eb78457bcc615a91cc2aab40fbbfe474b9e14 Mon Sep 17 00:00:00 2001 From: Vijay1306 Date: Sun, 24 Dec 2017 16:43:57 +0000 Subject: [PATCH 4/7] Done --- q05_read_csv_data/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..fa24022 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,10 @@ # Default imports import numpy as np -# Enter code here \ No newline at end of file +# Enter code here + +# Enter code here + +def read_ipl_data_csv(path,dtype='|S50'): + ipl_matches_array=np.genfromtxt(path,dtype='|S50',delimiter=',', skip_header=1) + return ipl_matches_array From 2be81b88648e7be99852dbbfc14bbde749c91ef3 Mon Sep 17 00:00:00 2001 From: Vijay1306 Date: Sun, 24 Dec 2017 17:14:34 +0000 Subject: [PATCH 5/7] Done --- q06_get_unique_matches_count/build.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..e4b0ffc 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,13 @@ # Default imports +import numpy as np from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv path = 'data/ipl_matches_small.csv' # Enter Code Here + +def get_unique_matches_count(): + ipl_matches_array = read_ipl_data_csv(path,dtype='|S50') + total_matches = ipl_matches_array[0:,0] + unique_count=np.unique(total_matches) + matches_count = len(unique_count) + return matches_count From e1ab2daa52ba8678b321be0ccd5afa67b80a7378 Mon Sep 17 00:00:00 2001 From: Vijay1306 Date: Sun, 31 Dec 2017 11:07:57 +0000 Subject: [PATCH 6/7] Done --- q07_get_unique_teams_set/build.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..91c4b3e 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,19 @@ # Default imports +import numpy as np from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv path = "data/ipl_matches_small.csv" # Enter Code Here + +def get_unique_teams_set(): + result = read_ipl_data_csv(path, dtype='|S50') + team1 = result[0:,3] + team1_final = np.unique(team1) + team1_set = set(team1_final) + + team2 = result[0:,4] + team2_final = np.unique(team2) + team2_set = set(team2_final) + + final_teams = team1_set | team2_set + return final_teams From c3febeda43a1b5507d569717825ea8390a93f28f Mon Sep 17 00:00:00 2001 From: Vijay1306 Date: Sun, 31 Dec 2017 11:59:36 +0000 Subject: [PATCH 7/7] Done --- q08_get_total_extras/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..ce238d3 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -4,4 +4,10 @@ path = 'data/ipl_matches_small.csv' -# Enter Code Here \ No newline at end of file +# Enter Code Here + +def get_total_extras(): + result = read_ipl_data_csv(path,dtype = '|S50') + extras = result[0:,17].astype(int) + total_extras = extras.sum(axis=0, dtype = np.int32) + return total_extras