From d802ca3b5b19513f43326f2424cba6fe65b5d1c8 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 20 Sep 2018 13:12:47 +0000 Subject: [PATCH 1/9] 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..43caf00 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 +array_zeros() + + From b624679d87e5c9201092d5a3fbd5bdc5ec61eed8 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 20 Sep 2018 13:21:20 +0000 Subject: [PATCH 2/9] Done --- q02_zeros_reshaped/build.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..a60f149 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,12 @@ +# %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= np.zeros((2,3,4)) + return zeros_array_reshaped +array_reshaped_zeros() + + From 7990674c4b28d15116ca9f012ade2a356157e647 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 20 Sep 2018 13:37:47 +0000 Subject: [PATCH 3/9] Done --- q03_create_3d_array/build.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..b55c625 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,11 @@ +# %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(): + n = 3**3 + x = np.array(range(n)).reshape((3,3,3)) + return x +create_3d_array() + From 11a966c969af84b6ccde0eb0ef076b4b07dfb486 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 20 Sep 2018 13:48:50 +0000 Subject: [PATCH 4/9] Done --- q04_read_csv_data_to_ndarray/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index fb71e6e..c454ede 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,12 @@ +# %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' + +# Enter code here +def read_csv_data_to_ndarray(path, dtype = np.float): + stan_array = np.genfromtxt(path, dtype=dtype, delimiter = ',', skip_header=1) + return stan_array +read_csv_data_to_ndarray(path) + -# Enter code here \ No newline at end of file From 047b38006987614c84d8ab97c8846d50a7e0c0cc Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 20 Sep 2018 14:17:04 +0000 Subject: [PATCH 5/9] Done --- q05_read_csv_data/build.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..36a4b0d 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,11 @@ +# %load q05_read_csv_data/build.py # Default imports import numpy as np +path = 'data/ipl_matches_small.csv' +# Enter code here +def read_ipl_data_csv(path, dtype = '|S50'): + ipl_matches_array = np.genfromtxt(path, dtype=dtype, delimiter=',', skip_header = 1) + return ipl_matches_array +read_ipl_data_csv(path) + -# Enter code here \ No newline at end of file From c840a303ce079a78ae5e3300f9a7d778719f77b4 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 20 Sep 2018 14:18:16 +0000 Subject: [PATCH 6/9] Done --- q05_read_csv_data/build.py | 1 - 1 file changed, 1 deletion(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 36a4b0d..5c6ca50 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -8,4 +8,3 @@ def read_ipl_data_csv(path, dtype = '|S50'): return ipl_matches_array read_ipl_data_csv(path) - From 61f50296b7d2eb09fbe6e999a4f4a3fd9c79f0b8 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 20 Sep 2018 14:24:19 +0000 Subject: [PATCH 7/9] 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..ac216fe 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,13 @@ +# %load q06_get_unique_matches_count/build.py # 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 = '|S100') + ipl_matches_array = np.unique(ipl_matches_array[1:,1]) + return len(ipl_matches_array) +get_unique_matches_count() + From 451e4413c1bb2fa5af50bfb806431f88b4c97195 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 20 Sep 2018 14:28:52 +0000 Subject: [PATCH 8/9] Done --- q07_get_unique_teams_set/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..74ab27c 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,13 @@ +# %load q07_get_unique_teams_set/build.py # 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" +path = 'data/ipl_matches_small.csv' # Enter Code Here +def get_unique_teams_set(): + ipl_data = read_ipl_data_csv(path, dtype = '|S100') + return set(np.unique(ipl_data[:,3:])) +get_unique_teams_set() + + From 11239307aaaa461f305f6fa6a3d366983de300f1 Mon Sep 17 00:00:00 2001 From: akashhchatterjee Date: Thu, 20 Sep 2018 14:36:02 +0000 Subject: [PATCH 9/9] Done --- q08_get_total_extras/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..7acfde8 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,15 @@ +# %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(): + ipl_extra = read_ipl_data_csv(path, dtype = '|S50') + sum_extra = np.array(ipl_extra[:,17],dtype = int).sum() + return sum_extra +get_total_extras() + +