From 733fa8e0761fe11d13c85b989ca691fe9582a7f6 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Thu, 20 Sep 2018 10:32:26 +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..38b3c1c 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((4,2,3)) + return zeros_array + +array_zeros() From 176c48fd5a426cea98674d9a18938368d642c757 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Thu, 20 Sep 2018 10:50:38 +0000 Subject: [PATCH 2/8] Done --- q02_zeros_reshaped/build.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..54c74e7 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,15 @@ +# %load q02_zeros_reshaped/build.py # Default imports import numpy as np -from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros +from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros # Write your code + +def array_reshaped_zeros(): + zeros_array=np.zeros((4,2,3)) + zeros_array_reshaped = zeros_array.reshape(2,3,4) + return zeros_array_reshaped + +array_reshaped_zeros() + + From cc32be9ce3420c248e8ba7b522ac1929f508e112 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sat, 22 Sep 2018 05:55:33 +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..527b7c6 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 +def create_3d_array(): + N = 27 + return np.arange(N).reshape(3,3,3) + + + + +create_3d_array() + + From 95e65224e1f886576a9394d21e567c3c21fe3d2b Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sat, 22 Sep 2018 06:42:32 +0000 Subject: [PATCH 4/8] Done --- q04_read_csv_data_to_ndarray/build.py | 14 ++++++++++++-- 1 file changed, 12 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..e85a4b3 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 +def read_csv_data_to_ndarray(path,dtype): + #path = './data/ipl_matches_small.csv' + return np.genfromtxt(path,delimiter=',',dtype=dtype,skip_header=1) + +# Enter code here +cally=read_csv_data_to_ndarray('./data/ipl_matches_small.csv','|S20') +cally + + + + From 19b96a89e811f075d0e28209ab6a954110946f3b Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sat, 22 Sep 2018 10:58:14 +0000 Subject: [PATCH 5/8] Done --- q05_read_csv_data/build.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..e8270a9 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,15 @@ +# %load q05_read_csv_data/build.py # Default imports import numpy as np -# Enter code here \ No newline at end of file +def read_ipl_data_csv(path,dtype): + #path='./data/ipl_matches_small.csv' + ipl_matches_array=np.genfromtxt(path, dtype=dtype, delimiter=',', skip_header=1) + return ipl_matches_array + +# Enter code here + +read_ipl_data_csv('./data/ipl_matches_small.csv','|S50') + + + From 7882318c877ca18a33ecd2d19a389ac4bf2dc7a1 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sat, 22 Sep 2018 12:41:06 +0000 Subject: [PATCH 6/8] Done --- q06_get_unique_matches_count/build.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..d3a7f03 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,26 @@ +# %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(): + varfile=np.genfromtxt(path,dtype='|S20',delimiter=',',skip_header=1,) + varcol=varfile[:,0] + ipl_matches_array = np.count_nonzero(np.unique(varcol)) + return ipl_matches_array +varfile=np.genfromtxt(path,dtype='|S20',delimiter=',',skip_header=1,) +get_unique_matches_count() +import numpy as np +path = 'data/ipl_matches_small.csv' +varfile +#for i in varfile: print(i[1],i[2]) +#np.unique(varfile[0]) +#varfile[0] +#ipl_ctr=np.ndarray(shape=(1,0), dtype=float, order='F') +varcol=varfile[:,0] + +np.unique(varcol) + + From c3308c683ca6f91e17c25769380bf79cbc2adb59 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sun, 23 Sep 2018 07:56:30 +0000 Subject: [PATCH 7/8] Done --- q07_get_unique_teams_set/build.py | 13 ++++++++++++- q08_get_total_extras/build.py | 9 ++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..d85d47e 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' +import numpy as np # Enter Code Here +def get_unique_teams_set(): + varfile=np.genfromtxt(path,delimiter=',',skip_header=1,dtype='|S50') + var1=np.unique(varfile[:,3]) + var2=np.unique(varfile[:,4]) + return np.union1d(var1,var2) + +get_unique_teams_set() + + diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..c0cd3c3 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(): + varfile=np.genfromtxt(path,delimiter=',',skip_header=1,dtype='int16') + return np.sum(varfile[:,17]) +get_total_extras() + + From 26e6d82e2ac9d0935adc308a17a66ab379072185 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sun, 23 Sep 2018 08:26:10 +0000 Subject: [PATCH 8/8] Done --- q07_get_unique_teams_set/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index d85d47e..4a5e9f6 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -9,7 +9,7 @@ def get_unique_teams_set(): varfile=np.genfromtxt(path,delimiter=',',skip_header=1,dtype='|S50') var1=np.unique(varfile[:,3]) var2=np.unique(varfile[:,4]) - return np.union1d(var1,var2) + return set(np.union1d(var1,var2)) get_unique_teams_set()