From 590f6204cff290bab726170d1ef9e751d87439f4 Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Wed, 5 Sep 2018 05:48:49 +0000 Subject: [PATCH 1/8] Done --- q01_zeros_array/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..3431fa5 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,14 @@ +# %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 - +def array_zeros(): + # Your solution + zeros_array = np.zeros(shape=(3,4,2)) + return (zeros_array) +print (array_zeros) + From c432b9e13071d35f81ec08d8369050771c4a589e Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Wed, 5 Sep 2018 05:58:32 +0000 Subject: [PATCH 2/8] Done --- q02_zeros_reshaped/build.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..8b5a6f3 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,17 @@ +# %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(shape=(3,4,2)) + zeros_array_reshaped = np.reshape(zeros_array,(2,3,4)) + return zeros_array_reshaped; + +print (array_reshaped_zeros()) + + + + From c0b8e738f1e75d0f57fc0602f746e9aa03cd20c8 Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sun, 9 Sep 2018 15:00:11 +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..f9c8509 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 +# Your solution + +def create_3d_array(): + arr=np.arange(27).reshape(3,3,3) + return (arr) + +print (create_3d_array()) + + + From 59d2182671eb44735bf89ec92428a7b4f1ec7f74 Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Tue, 11 Sep 2018 05:57:14 +0000 Subject: [PATCH 4/8] Done --- q04_read_csv_data_to_ndarray/build.py | 18 ++++++++++++++++-- 1 file changed, 16 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..e9aaa09 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" +from numpy import genfromtxt +path = './data/ipl_matches_small.csv' + +# Enter code here +def read_csv_data_to_ndarray(path,dtype): + nparray=np.genfromtxt(path,dtype=dtype, delimiter=',', skip_header=1) + return nparray +print (read_csv_data_to_ndarray(path,str)) + + + + + + + -# Enter code here \ No newline at end of file From 1700170acd78d9541c281b0f0dfe7697e084456a Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sat, 22 Sep 2018 08:27:10 +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..f087b7f 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 + +from numpy import genfromtxt +path = 'data/ipl_matches_small.csv' + +def read_ipl_data_csv(path,dtype = np.float64): + ipl_matches_array= np.genfromtxt(path,dtype='|S50',skip_header = 1 , delimiter = ',') + return ipl_matches_array + + + + + + + From 05c22589b542d14f3e4485f4c3c9a769ff3f97a3 Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sat, 22 Sep 2018 10:14:03 +0000 Subject: [PATCH 6/8] Done --- q06_get_unique_matches_count/build.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..787676e 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,12 @@ +# %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 +def get_unique_matches_count(): + ipl_matches_array = read_ipl_data_csv(path, dtype='|S100') + return len(set(ipl_matches_array[:,0])) +get_unique_matches_count() + + From d0099c35e799214bbae3108658d1d3199795f8ec Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sat, 22 Sep 2018 10:16:18 +0000 Subject: [PATCH 7/8] Done --- q07_get_unique_teams_set/build.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..82eb7c3 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,16 @@ +# %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' # Enter Code Here +def get_unique_teams_set(): + teams = [] + for i in read_ipl_data_csv(path, dtype='|S100'): + if not i[3] in teams: + teams.append(i[3]) + if not i[4] in teams: + teams.append(i[4]) + return set(teams) + + From a1b6b6c18389f3e91cac2c1fc8bc9ee01c6f3bed Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sat, 22 Sep 2018 10:19:25 +0000 Subject: [PATCH 8/8] 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..854e264 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(): + data = read_ipl_data_csv(path, dtype='|S100')[:,17] + extras =sum([int(run) for run in data]) + return extras +get_total_extras() + +