From e27f1d1df748f5ed05820182294e2588a5abe17c Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Tue, 4 Sep 2018 19:23:28 +0000 Subject: [PATCH 1/8] Done --- q01_zeros_array/build.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..ee624dd 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,15 @@ +# %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 + + + From c52bf8e02bf6523b9dd77a8def45c9fff04c3b90 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Tue, 4 Sep 2018 19:33:18 +0000 Subject: [PATCH 2/8] Done --- q02_zeros_reshaped/build.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..3b53da3 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,21 @@ +# %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 +def array_reshaped_zeros(): + zeros_array_reshaped = array_zeros().reshape(2,3,4) + return zeros_array_reshaped + + + + + + + + + + + + From b37835d387c200af5505bee3d2bd935cf8abd287 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Tue, 4 Sep 2018 19:50:49 +0000 Subject: [PATCH 3/8] Done --- q03_create_3d_array/build.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..7cb12f7 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,15 @@ +# %load q03_create_3d_array/build.py # Default Imports import numpy as np -# Enter solution here \ No newline at end of file +# Enter solution here +def create_3d_array(): + #specify desired dimensions + dim1 = 3; dim2 = 3; dim3 = 3 + elements = dim1*dim2*dim3 + variable = np.arange(elements).reshape(dim1,dim2,dim3) + return variable + + + + From 1e77bbe18cc3906a2c93b0025f308ac79ea4e7b0 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Tue, 11 Sep 2018 20:55:57 +0000 Subject: [PATCH 4/8] Done --- q03_create_3d_array/build.py | 1 + q04_read_csv_data_to_ndarray/build.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7cb12f7..aacf8c4 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -13,3 +13,4 @@ def create_3d_array(): + diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index fb71e6e..8bd9544 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,19 @@ +# %load q04_read_csv_data_to_ndarray/build.py # Default Imports import numpy as np -path = "./data/ipl_matches_small.csv" +path = './data/ipl_matches_small.csv' +dtype = None + +# Enter code here +def read_csv_data_to_ndarray(path,dtype): + data = np.genfromtxt(path, delimiter = ',',dtype=dtype,skip_header=1) + return data + +read_csv_data_to_ndarray(path,dtype) +#type(data) +#print(data) + + + + -# Enter code here \ No newline at end of file From 22ba5770a39b7d7653db96a5a03d21606806fdf6 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 13 Sep 2018 05:48:03 +0000 Subject: [PATCH 5/8] Done --- q05_read_csv_data/build.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..44962ce 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,16 @@ +# %load q05_read_csv_data/build.py # Default imports import numpy as np +path = './data/ipl_matches_small.csv' +dtype = '|S50' + +# Enter code here +def read_ipl_data_csv(path,dtype): + ipl_matches_array = np.genfromtxt(path,delimiter=',',dtype=dtype,skip_header=1) + return ipl_matches_array + +read_ipl_data_csv(path,dtype) + + + -# Enter code here \ No newline at end of file From 154c6cab751d03624aafccd5dd2ceec5051861c0 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 13 Sep 2018 20:04:05 +0000 Subject: [PATCH 6/8] Done --- q06_get_unique_matches_count/build.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..d71151d 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,23 @@ +# %load q06_get_unique_matches_count/build.py # Default imports from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv -path = 'data/ipl_matches_small.csv' +#path = 'data/ipl_matches_small.csv' #path for reference as function should not take any parameter. +import numpy as np # Enter Code Here +def get_unique_matches_count(): + + #loading the file in a variable + y=np.genfromtxt('data/ipl_matches_small.csv',dtype=None,delimiter=',') + + #Getting unique match code ids by using numpy unique function + #Subtracting 1 from total count as one value among unique cinstitutes for the header + ipl_matches_array = len(np.unique(y[:,0]))-1 + return ipl_matches_array + + +get_unique_matches_count() + + + + From 79d603bf867e1b3a3e60852c03b5f6d6d23e8a8a Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 13 Sep 2018 20:56:28 +0000 Subject: [PATCH 7/8] Done --- q07_get_unique_teams_set/build.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..b22db77 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,31 @@ +# %load q07_get_unique_teams_set/build.py # Default imports from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv -path = "data/ipl_matches_small.csv" + +#Path of the csv file to be passed onto function +path = 'data/ipl_matches_small.csv' # Enter Code Here +def get_unique_teams_set(): + + #Loading csv file + a = read_ipl_data_csv(path,dtype=None) + + #creating empty set variables so that same team name doesn't get added repeatedly. + team1 = set() + team2 = set() + + #Looping thru list and getting inside tuple for team name fetching + for i,v in enumerate(a): + team1.add(a[i][3]) + team2.add(a[i][4]) + + #returning union of two + return team1.union(team2) # team1|team2 would do as well. + +#Call to a function - +get_unique_teams_set() + + + + From b7b511345ec6f18e49786131fd6f9682a662c571 Mon Sep 17 00:00:00 2001 From: vivekshingate Date: Thu, 13 Sep 2018 21:15:23 +0000 Subject: [PATCH 8/8] Done --- q08_get_total_extras/build.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..a1048a3 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,23 @@ +# %load q08_get_total_extras/build.py # Default Imports from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv import numpy as np path = 'data/ipl_matches_small.csv' -# Enter Code Here \ No newline at end of file +# Enter Code Here +def get_total_extras(): + + #reading file using np.genfromtxt + a = np.genfromtxt(path,dtype=None,delimiter=',',skip_header=1) + + #Creating an empty list to store extra runs. + extras = [] + + #Looping thru each deliveries' extra and storing the value in list + for i,v in enumerate(a): + extras.append(a[i][17]) #17th index is the extra column + return sum(extras) +get_total_extras() + +