From 64f0b34d3a49ecb2189305a7acb1120d10570d77 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Sun, 16 Sep 2018 09:25:04 +0000 Subject: [PATCH 1/8] Done --- q01_zeros_array/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..a2c4248 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,16 @@ +# %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 + + + From ab6b2413137083f382ca3c247d0b8e586030889c Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Sun, 16 Sep 2018 09:45:08 +0000 Subject: [PATCH 2/8] Done --- q02_zeros_reshaped/build.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..86cb08a 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,18 @@ +# %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 +import sys, os +sys.path.append(os.path.join(os.path.dirname(os.curdir), '..' )) +import numpy as np + +def array_reshaped_zeros(): + + zeros_array =np.zeros((3,4,2)) + zeros_array_reshaped=np.reshape(zeros_array,(2,3,4)) + + return zeros_array_reshaped + + + From b01eb9f42c22585342511ed68faefa74e326bccc Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Wed, 26 Sep 2018 16:01:00 +0000 Subject: [PATCH 3/8] Done --- q03_create_3d_array/build.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..e6cec23 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,14 @@ +# %load q03_create_3d_array/build.py # Default Imports import numpy as np -# Enter solution here \ No newline at end of file + +def create_3d_array(): + a=np.arange(0,27) + a=a.reshape(3,3,3) + return a + + + + + From deccc1e78c77231aba5c52d1702d020d11b1c0fe Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Wed, 26 Sep 2018 18:55:38 +0000 Subject: [PATCH 4/8] 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..baa8f06 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" +import csv +path = './data/ipl_matches_small.csv' + + + +def read_csv_data_to_ndarray(path,datatype=np.float64): + data = np.genfromtxt(path, dtype=datatype,delimiter=',', skip_header=1) + return data -# Enter code here \ No newline at end of file From 148fc1763b9b7ee762e0e19ce3877ca26c896a90 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Wed, 26 Sep 2018 19:01:39 +0000 Subject: [PATCH 5/8] Done --- q05_read_csv_data/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..421a9aa 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,12 @@ +# %load q05_read_csv_data/build.py # Default imports import numpy as np +import csv +path = './data/ipl_matches_small.csv' + +def read_ipl_data_csv(path,dtype='float64'): + ipl_matches_array=np.genfromtxt(path,dtype=dtype,delimiter=',',skip_header=1) + return ipl_matches_array +read_ipl_data_csv('./data/ipl_matches_small.csv') + -# Enter code here \ No newline at end of file From 2df84e6e35f6a224847a5020c026f548c1c10b19 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Thu, 27 Sep 2018 18:24:16 +0000 Subject: [PATCH 6/8] Done --- q06_get_unique_matches_count/build.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..c745194 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,20 @@ +# %load q06_get_unique_matches_count/build.py # Default imports from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv +import numpy as np +import csv path = 'data/ipl_matches_small.csv' -# Enter Code Here +def get_unique_matches_count(): + with open(path,'r') as f: + reader=csv.reader(f, delimiter=',') + header=next(reader) + data=list(reader) + arr=np.array(data) + ar2=arr[0:,0:1] + ar3=np.unique(ar2) + ipl_matches_array=np.size(ar3) + return ipl_matches_array +get_unique_matches_count() + + From 5813a6ac297e4f9189169cbe62c6e98ad254ffc7 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Thu, 27 Sep 2018 18:51:26 +0000 Subject: [PATCH 7/8] Done --- q07_get_unique_teams_set/build.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..d03500f 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,21 @@ +# %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" +import numpy as np +import csv +path = 'data/ipl_matches_small.csv' + +def get_unique_teams_set(): + with open(path,'r') as f: + reader=csv.reader(f, delimiter=',') + header=next(reader) + data=list(reader) + ar1=np.array(data) + team1=set(ar1[:,3].astype('|S50')) + team2=set(ar1[:,4].astype('|S50')) + unio=team1.union(team2) + return unio + +get_unique_teams_set() + -# Enter Code Here From 8e4813a1aeb9b378b6e6fa0fbf0c43bed0921795 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Thu, 27 Sep 2018 18:57:00 +0000 Subject: [PATCH 8/8] Done --- q08_get_total_extras/build.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..130ebcd 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,21 @@ +# %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 +import csv path = 'data/ipl_matches_small.csv' -# Enter Code Here \ No newline at end of file +def get_total_extras(): + with open(path,'r') as f: + reader=csv.reader(f, delimiter=',') + header=next(reader) + data=list(reader) + arr=np.array(data) + extras=np.hstack(arr[0:,17:18]) + arr=np.array(extras, dtype=np.int32) + data=list(arr) + return np.sum(data) +get_total_extras() + +