From 973407e62e18960c6976333beecaad2444db3850 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Wed, 31 Oct 2018 18:03:58 +0000 Subject: [PATCH 1/8] 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..14654b8 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 # Your solution +def array_zeros(): + zeros_array=np.zeros([3,4,2]) + return zeros_array + +array_zeros() From e0822c35e8868b2d9d10321dcf42381ffded6909 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Wed, 31 Oct 2018 18:31:50 +0000 Subject: [PATCH 2/8] 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..ee47ea7 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=array_zeros().reshape(2,3,4) + return zeros_array_reshaped +array_zeros().reshape(2,3,4) + + From b75ce78da5180d88ed29b591354c9dd814833dbf Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 13 Nov 2018 13:00:25 +0000 Subject: [PATCH 3/8] Done --- q03_create_3d_array/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..3241a12 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,10 @@ +# %load q03_create_3d_array/build.py # Default Imports import numpy as np +def create_3d_array(): + return np.arange(0,27).reshape(3,3,3) +# Enter solution here +a = np.arange(0,27).reshape(3,3,3) +a + -# Enter solution here \ No newline at end of file From 50f3cd2cd8957cabcd8cbb978934f931145ab9b5 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 13 Nov 2018 13:02:45 +0000 Subject: [PATCH 4/8] Done --- q04_read_csv_data_to_ndarray/build.py | 10 ++++++++-- 1 file changed, 8 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..82422e9 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,11 @@ +# %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): + return np.genfromtxt(path,delimiter=',',dtype=dtype,skip_header=1) + + -# Enter code here \ No newline at end of file From 6589cf41aa765e61af68f2efd8101ac9192d4e34 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 13 Nov 2018 13:07:22 +0000 Subject: [PATCH 5/8] 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..6bb7516 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 -# Enter code here \ No newline at end of file +# Enter code here +def read_ipl_data_csv(path,dtype): + ipl_matches_array = np.genfromtxt(path,dtype=dtype,delimiter=',',skip_header=1) + return ipl_matches_array + + + From 65a1e208a4098501aa2cdda4d1bb406144d8284f Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 13 Nov 2018 13:17:07 +0000 Subject: [PATCH 6/8] Done --- q06_get_unique_matches_count/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..92d18bf 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 from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv path = 'data/ipl_matches_small.csv' - +import numpy as np # Enter Code Here +def get_unique_matches_count(): + x = np.genfromtxt(path,dtype=int,delimiter=',',skip_header=1) + ipl_matches_array = len(np.unique(x[:,0])) + return ipl_matches_array +get_unique_matches_count() + + From 92d8918c56570929bb3b5a0dd9566ed385ae71d4 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 13 Nov 2018 13:32:55 +0000 Subject: [PATCH 7/8] Done --- q07_get_unique_teams_set/build.py | 16 +++++++++++++++- q08_get_total_extras/build.py | 9 ++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..e1827e5 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,19 @@ +# %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' +import numpy as np # Enter Code Here +def get_unique_teams_set(): + x=np.genfromtxt(path,dtype=str,delimiter=',',skip_header=1,usecols=3) + y=np.genfromtxt(path,dtype=str,delimiter=',',skip_header=1,usecols=4) + + a=np.unique(x) + b=np.unique(y) + v=np.union1d(b,a) + return set(v) +get_unique_teams_set() +set() + + diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..4887382 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,14 @@ +# %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(): + x=np.genfromtxt(path,dtype=None,delimiter=',',skip_header=1,usecols=17) + return sum(x) +get_total_extras() + + From 3cfadceb0ce1f64c6f7809432f75984003018deb Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Wed, 23 Jan 2019 17:08:27 +0000 Subject: [PATCH 8/8] Done --- q07_get_unique_teams_set/build.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index e1827e5..6279f26 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -2,17 +2,19 @@ # 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 numpy as np # Enter Code Here def get_unique_teams_set(): - x=np.genfromtxt(path,dtype=str,delimiter=',',skip_header=1,usecols=3) - y=np.genfromtxt(path,dtype=str,delimiter=',',skip_header=1,usecols=4) - a=np.unique(x) - b=np.unique(y) - v=np.union1d(b,a) - return set(v) + ipl_matches_array=np.genfromtxt(path, dtype='|S50',delimiter=',',skip_header=1) + + u1=list(np.unique(ipl_matches_array[:,3])) + u2=list(np.unique(ipl_matches_array[:,4])) + + u=set(u1+u2) + + return u get_unique_teams_set() set()