From 8c448c1839e8cef934a463bb10dc95df6e30c84d Mon Sep 17 00:00:00 2001 From: tracedence Date: Sat, 8 Sep 2018 04:46:39 +0000 Subject: [PATCH 1/8] Done --- q01_zeros_array/build.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..3cddb9b 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,19 @@ +# %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)) + #print(zeros_array.max()) + + return zeros_array + +array_zeros() + + From e9ad91924de5812b4b6192b3953e7fb10942cc09 Mon Sep 17 00:00:00 2001 From: tracedence Date: Sat, 8 Sep 2018 04:51:54 +0000 Subject: [PATCH 2/8] Done --- q02_zeros_reshaped/build.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..410237e 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,24 @@ +# %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 = np.zeros((3,4,2)) + + #print(zeros_array) + + zeros_array_reshaped = zeros_array.reshape((2,3,4)) + + #print(type(zeros_array_reshaped)) + + return zeros_array_reshaped + +array_reshaped_zeros() + + + + From 191904a809890d9354e74639ef46f1108fd981bc Mon Sep 17 00:00:00 2001 From: tracedence Date: Sat, 8 Sep 2018 05:48:04 +0000 Subject: [PATCH 3/8] Done --- q03_create_3d_array/build.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..382375f 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,21 @@ +# %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 * 3 + + arr = np.arange(N) + + arr1 = arr.reshape((3,3,3)) + + #print(arr1) + + return arr1 + +create_3d_array() + + From 958cfbbc8488d8d3ee13691149280f6fdc9c220d Mon Sep 17 00:00:00 2001 From: tracedence Date: Sat, 8 Sep 2018 06:42:48 +0000 Subject: [PATCH 4/8] Done --- q04_read_csv_data_to_ndarray/build.py | 16 ++++++++++++++-- 1 file changed, 14 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..dbcb787 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,17 @@ +# %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.float64): + + arr_of_small_csv = np.genfromtxt(path,dtype, skip_header = 1, delimiter = ',') + + a = np.set_printoptions(threshold = np.nan) + + return arr_of_small_csv + +read_csv_data_to_ndarray(path) + -# Enter code here \ No newline at end of file From e195240c3aced95ca20a577bb49faad09e2ab12b Mon Sep 17 00:00:00 2001 From: tracedence Date: Sat, 8 Sep 2018 09:06:00 +0000 Subject: [PATCH 5/8] Done --- q05_read_csv_data/build.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..f8b7da5 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,19 @@ +# %load q05_read_csv_data/build.py # Default imports import numpy as np -# Enter code here \ No newline at end of file +# Enter code here +def read_ipl_data_csv(path, dtype = np.float64): + + ipl_matches_array = np.genfromtxt(path, dtype= '|S50' , skip_header = 1, delimiter = ',') + + np.set_printoptions(threshold= 1) + + return ipl_matches_array + +path = './data/ipl_matches_small.csv' +read_ipl_data_csv(path) + + + + From 71bb156885bb69d93eb63f50736e3e569a932b10 Mon Sep 17 00:00:00 2001 From: tracedence Date: Sun, 9 Sep 2018 05:43:19 +0000 Subject: [PATCH 6/8] Done --- q06_get_unique_matches_count/build.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..3b01111 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,22 @@ +# %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(): + + matches = np.genfromtxt(path, skip_header = 1, delimiter = ',') + + #np.set_printoptions(threshold = np.nan) + + ipl_matches_array = len(set(matches[:,0])) + + return ipl_matches_array + +get_unique_matches_count() + + + + From bc0eba03a23d659fe4cae3eb41b625a7c4b50479 Mon Sep 17 00:00:00 2001 From: tracedence Date: Sun, 9 Sep 2018 06:54:11 +0000 Subject: [PATCH 7/8] Done --- q07_get_unique_teams_set/build.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..4d1fcb6 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,22 @@ +# %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(): + + #np.set_printoptions(threshold = np.nan) + matches = read_ipl_data_csv(path, dtype = '|S50') + + team1 = list(matches[:,3]) + team2 = list(matches[:,4]) + + return set(team2 + team1) + +get_unique_teams_set() + + + From c53418442943431b701d81d8776eb0a3d98d8457 Mon Sep 17 00:00:00 2001 From: tracedence Date: Mon, 10 Sep 2018 05:49:44 +0000 Subject: [PATCH 8/8] Done --- q08_get_total_extras/build.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..ae89b85 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,25 @@ +# %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(): + + matches = np.genfromtxt(path, dtype = np.float64,skip_header = 1, delimiter = ',') + #matches[] + + #np.set_printoptions(threshold = np.nan) + count = 0 + + for number in matches[:,17]: + count = count + number + + return count + +get_total_extras() + + +