From 3d254f2eca6e976c27fd649a171de552a4b9e24b Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Fri, 7 Sep 2018 09:57:42 +0000 Subject: [PATCH 1/8] Done --- q01_zeros_array/build.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..df4c798 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,13 @@ -# Default Imports -import sys, os -sys.path.append(os.path.join(os.path.dirname(os.curdir), '..' )) +#%load q01_zeros_array/build.py + +# import numpy as np +def array_zeros(): + #import numpy as np + + arr=np.zeros((3,4,2)) + return arr + #print(arr) -# Your solution From ce1255c1c78728fd9dc7072154285a5e0bcd30cb Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Fri, 7 Sep 2018 11:56:12 +0000 Subject: [PATCH 2/8] Done --- q02_zeros_reshaped/build.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..cbbf4dc 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,11 @@ -# Default imports +#%load q02_zeros_reshaped/build.py import numpy as np -from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros +def array_reshaped_zeros(): + + arr=np.zeros((3,4,2)) + zeros_array_reshaped=arr.reshape((2,3,4)) + #print(arr1) + return zeros_array_reshaped + + -# Write your code From e25d0a5556aac70015c09510ca9d8a1b52b5df3d Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sat, 15 Sep 2018 12:05:22 +0000 Subject: [PATCH 3/8] Done --- q03_create_3d_array/build.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..8ab3b29 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,12 @@ -# Default Imports +#%load q03_create_3d_array/build.py + import numpy as np -# Enter solution here \ No newline at end of file +def create_3d_array() : + + + arr=np.arange(27).reshape(3,3,3) + + return arr + + From 9688fa91b24eac365effe3e3d0e7201dbc8a743a Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sat, 15 Sep 2018 13:18:40 +0000 Subject: [PATCH 4/8] Done --- q04_read_csv_data_to_ndarray/build.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index fb71e6e..935de8d 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,20 @@ -# Default Imports +#%load q04_read_csv_data_to_ndarray/build.py + import numpy as np -path = "./data/ipl_matches_small.csv" -# Enter code here \ No newline at end of file +path='./data/ipl_matches_small.csv' +dtype= '|S20' +def read_csv_data_to_ndarray(path,dtype): + + arr=np.genfromtxt(path,delimiter=',',dtype=dtype,skip_header=1) +#print(type(arr)) +#print(arr.dtype) + + + return arr + +read_csv_data_to_ndarray(path,dtype) + + + + From 4c1fbb34d226e6be76373cb019d43bdef2ee4149 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sat, 15 Sep 2018 13:27:27 +0000 Subject: [PATCH 5/8] Done --- q05_read_csv_data/build.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..df26953 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,16 @@ -# Default imports +#%load q05_read_csv_data/build.py + import numpy as np -# Enter code here \ No newline at end of file +path='./data/ipl_matches_small.csv' +dtype='|S50' + +def read_ipl_data_csv(path,dtype): + + ipl_matches_array=np.genfromtxt(path,delimiter=',',skip_header=1,dtype=dtype) + +#print(ipl_matches_array) + return ipl_matches_array + + + From 5abefcda33a86d0055946e5623385f1a5d205c11 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sat, 15 Sep 2018 13:55:46 +0000 Subject: [PATCH 6/8] Done --- q06_get_unique_matches_count/build.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..068eed2 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,22 @@ -# Default imports -from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv -path = 'data/ipl_matches_small.csv' +#%load q06_get_unique_matches_count/build.py + +import numpy as np + +path='./data/ipl_matches_small.csv' + +def get_unique_matches_count(): + + ipl_matches_array=np.genfromtxt(path,delimiter=',',skip_header=1,dtype='|S20') +#print(ipl_matches_array) + + nouniquecounts=np.unique(ipl_matches_array[:,0],axis=0) + nocounts=nouniquecounts.size + + +#print(noCounts.size) + return nocounts + + + + -# Enter Code Here From db492b16c71e6118dd3fec26d47dc038b41125a0 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sat, 15 Sep 2018 21:10:09 +0000 Subject: [PATCH 7/8] Done --- q07_get_unique_teams_set/build.py | 38 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..9d4c837 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,35 @@ -# Default imports -from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv -path = "data/ipl_matches_small.csv" +#%load q07_get_unique_teams_set/build.py/ + +import numpy as np + +path='./data/ipl_matches_small.csv' + +def get_unique_teams_set(): + arr=np.genfromtxt(path,delimiter=',',skip_header=1,dtype='|S25') + + #team1=arr[:,2:] + + team1=np.unique(arr[:,3],axis=0) + team2=np.unique(arr[:,4],axis=0) + + uniqueteams=np.union1d(team1,team2) + #Team=team1.union(team2) + x=set(uniqueteams.flat) + +#print(team1) +#print(team2) +#print(uniqueteams) + return (x) + + + +get_unique_teams_set() + + + + + + + + -# Enter Code Here From 418bbae895608dfa30614f138abf9291b1c34183 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Tue, 18 Sep 2018 05:45:24 +0000 Subject: [PATCH 8/8] Done --- q08_get_total_extras/build.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..e7302ab 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,17 @@ -# Default Imports -from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv +#%load q08_get_total_extras/build.py + import numpy as np -path = 'data/ipl_matches_small.csv' +path='./data/ipl_matches_small.csv' + +def get_total_extras(): + + arr=np.genfromtxt(path,delimiter=',',skip_header=1,dtype=int) +#arr + #print(sum(arr[:,17])) + ext=sum(arr[:,17]) + return ext + +get_total_extras() + -# Enter Code Here \ No newline at end of file