From 3dbdcce6d59b91caa6e17edca32e4c64134b05ad Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sat, 15 Sep 2018 11:45:47 +0000 Subject: [PATCH 1/9] Done --- q01_zeros_array/build.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..b0fdc30 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,9 @@ -# Default Imports -import sys, os -sys.path.append(os.path.join(os.path.dirname(os.curdir), '..' )) -import numpy as np -# Your solution +import numpy as np +def array_zeros(): + + zeros_array=np.zeros((3,4,2)) + + return zeros_array From 67055ebab368872ed8b146ee0d9ab90e708654b8 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sat, 15 Sep 2018 11:52:03 +0000 Subject: [PATCH 2/9] Done --- q02_zeros_reshaped/build.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..ae82c9a 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,10 @@ -# 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=np.zeros((3,4,2)) + zeros_array_reshaped=zeros_array.reshape(2,3,4) + + return zeros_array_reshaped + From 3f350bc21fb7959ea8f3db91008b8478430629c9 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sat, 15 Sep 2018 12:04:23 +0000 Subject: [PATCH 3/9] Done --- q03_create_3d_array/build.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..7f15c81 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,10 @@ -# Default Imports + import numpy as np -# Enter solution here \ No newline at end of file +def create_3d_array(): + + arr=np.arange(27) + array=arr.reshape(3,3,3) + + return array + From de9ca1d89d42b1173b96bba3ff827cf80d2866d5 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sat, 15 Sep 2018 14:06:09 +0000 Subject: [PATCH 4/9] Done --- q04_read_csv_data_to_ndarray/build.py | 15 +++++++++++++-- q05_read_csv_data/build.py | 13 ++++++++++++- 2 files changed, 25 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..7b631c5 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,16 @@ +# %load q04_read_csv_data_to_ndarray/build.py # Default Imports 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' + + +def read_csv_data_to_ndarray(path,dtype=np.float64): + array=np.genfromtxt(path, dtype=dtype,delimiter=',',skip_header=1) + + return array + + +# Enter code here + + diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..44793b2 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,15 @@ +# %load q05_read_csv_data/build.py # Default imports import numpy as np -# Enter code here \ No newline at end of file +path = './data/ipl_matches_small.csv' + +def read_ipl_data_csv(path,dtype=np.float64): + + ipl_matches_array=array=np.genfromtxt(path, dtype='|S50',delimiter=',',skip_header=1) + + return ipl_matches_array + +# Enter code here + + From ffeb1b5745d9e547ff7bd42eaa07b9b68fd59afd Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sun, 16 Sep 2018 12:04:43 +0000 Subject: [PATCH 5/9] Done --- q05_read_csv_data/build.py | 2 +- q06_get_unique_matches_count/build.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 44793b2..b897845 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -6,7 +6,7 @@ def read_ipl_data_csv(path,dtype=np.float64): - ipl_matches_array=array=np.genfromtxt(path, dtype='|S50',delimiter=',',skip_header=1) + ipl_matches_array=np.genfromtxt(path, dtype='|S50',delimiter=',',skip_header=1) return ipl_matches_array diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..e24a436 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,15 @@ +# %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' -# Enter Code Here +import numpy as np + +def get_unique_matches_count(): + + i=len(np.unique(ipl_matches_array[:,1])) + ipl_matches_array + + return ipl_matches_array + + From ec08dcee97f4c519cc038584ef7266370a066532 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sun, 16 Sep 2018 12:09:09 +0000 Subject: [PATCH 6/9] Done --- q06_get_unique_matches_count/build.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index e24a436..4dad567 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -7,8 +7,9 @@ def get_unique_matches_count(): - i=len(np.unique(ipl_matches_array[:,1])) - ipl_matches_array + + ipl_matches_array=len(np.unique(ipl_matches_array[:,1])) + return ipl_matches_array From a80e0d6b8934230cd7d8ad7050f5d7203fd343ec Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sun, 16 Sep 2018 12:44:27 +0000 Subject: [PATCH 7/9] Done --- q07_get_unique_teams_set/build.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..eef11c3 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,23 @@ +# %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 = 'data/ipl_matches_small.csv' +import numpy as np # Enter Code Here +def get_unique_teams_set(): + + ipl_matches_array=np.genfromtxt(path, dtype='|S50',delimiter=',',skip_header=1) + + u1=list(np.unique(ipl_matches_array[:,3])) + u2=list(np.unique(ipl_matches_array[:,4])) + + + + u=set(u1+u2) + + + return u + + + From 13ef247556d5c0cf2d5441b68ebbae0452ec65dc Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sun, 16 Sep 2018 12:45:43 +0000 Subject: [PATCH 8/9] Done --- q06_get_unique_matches_count/build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 4dad567..0c5d288 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -7,8 +7,9 @@ def get_unique_matches_count(): + ipl_matches_array=np.genfromtxt(path, dtype='|S50',delimiter=',',skip_header=1) - ipl_matches_array=len(np.unique(ipl_matches_array[:,1])) + ipl_matches_array=len(np.unique(ipl_matches_array[:,0])) return ipl_matches_array From 746d3fb603c0c8ea98b70edb941a2a7ffb21d1a0 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sun, 16 Sep 2018 12:51:51 +0000 Subject: [PATCH 9/9] Done --- q08_get_total_extras/build.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..7c42a46 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,16 @@ +# %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 +def get_total_extras(): + + ipl_matches_array=np.genfromtxt(path, dtype=int ,delimiter=',',skip_header=1) + + extras=sum(ipl_matches_array[:,17]) + + return extras + +