From 87e08105cd0be49e3f16b747f74b10234fba6f15 Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Sat, 15 Sep 2018 08:54:52 +0000 Subject: [PATCH 1/7] Done --- q01_zeros_array/build.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..49be674 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(): + zeros_array = np.zeros([3,4,2]) + return zeros_array # Your solution + + From 7dc2484c3d30c11b59d6e53400b879ffd433dc5c Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Sat, 15 Sep 2018 09:03:42 +0000 Subject: [PATCH 2/7] Done --- q02_zeros_reshaped/build.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..4eade3a 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 - +def array_reshaped_zeros(): + var=array_zeros().reshape((2,3,4)) + return var # Write your code + + + + From 11a628d29733db09638235c8f9aa21c7e483030a Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Tue, 2 Oct 2018 15:08:25 +0000 Subject: [PATCH 3/7] Done --- q03_create_3d_array/build.py | 10 +++++++++- q04_read_csv_data_to_ndarray/build.py | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..f6b0f0f 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,12 @@ +# %load q03_create_3d_array/build.py # Default Imports import numpy as np +def create_3d_array(): + N = np.zeros((3, 3, 3)).size + numbers = np.arange(0,N) + return np.reshape(numbers,(3,3,3)) +# Enter solution here + + + -# Enter solution here \ No newline at end of file diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index fb71e6e..eca31f2 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,15 @@ +# %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): + from numpy import genfromtxt + my_data = genfromtxt(path, delimiter=',', skip_header=1).astype(np.float64) + return my_data +# Enter code here + + + + + From e6c1ab836c473db32d1c49cf0fcb6b80e73bc1a7 Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Tue, 2 Oct 2018 15:11:14 +0000 Subject: [PATCH 4/7] Done --- q04_read_csv_data_to_ndarray/build.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index eca31f2..50abf99 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -3,10 +3,9 @@ import numpy as np path = './data/ipl_matches_small.csv' -def read_csv_data_to_ndarray(path, dtype): +def read_csv_data_to_ndarray(path=path, input_dtype = np.float64): from numpy import genfromtxt - my_data = genfromtxt(path, delimiter=',', skip_header=1).astype(np.float64) - return my_data + return np.genfromtxt(path, delimiter=',', dtype = input_dtype, skip_header=1) # Enter code here From 8ce519b5cdf73f575c9d60b79ee2b1ca28d1291e Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Tue, 2 Oct 2018 15:13:56 +0000 Subject: [PATCH 5/7] 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..a41285d 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 +path = './data/ipl_matches_small.csv' +def read_ipl_data_csv(path, dtype='|S50'): + ipl_matches_array = np.genfromtxt(path, delimiter= ',', dtype=dtype, skip_header=1) + return ipl_matches_array + +read_ipl_data_csv(path) +# Enter code here + -# Enter code here \ No newline at end of file From 6f3f2b7faed82fe7e7c475c3613f538c2ffa8ba3 Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Tue, 2 Oct 2018 15:17:50 +0000 Subject: [PATCH 6/7] Done --- q06_get_unique_matches_count/build.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..20938f9 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,16 @@ +# %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' +import numpy as np +def get_unique_matches_count(path=path): + data = np.genfromtxt(path, delimiter= ',', skip_header=1) + ipl_matches_array = len(set(data[:,0])) + return ipl_matches_array + +get_unique_matches_count(path) # Enter Code Here + + + From 2657b443e0e9f4aac43e798a0e7b48ba023d613e Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Tue, 2 Oct 2018 15:23:44 +0000 Subject: [PATCH 7/7] 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..e5084da 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(): + data= read_ipl_data_csv(path,dtype='|S50') + team1 = set(data[:,3]) + team2 = set(data[:,4]) + teamUnion = set().union(team1,team2) + return teamUnion +get_unique_teams_set() + + +