diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..de8bca8 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() +#please make sure you save and run the code before test diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..c800cfc 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,19 @@ +# %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_zeroes(): + zeros_array = np.zeros((3,4,2)) + return zeros_array +def array_reshaped_zeros(): + zeros_array_reshaped = np.zeros((2,3,4)) + return zeros_array_reshaped +print('Zero arrays with dimension(3,4,2)') +print(array_zeros()) +print(' ') +print('Zero arrays after Reshape with dimensions (2,3,4)') +print(array_reshaped_zeros()) + + diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..f45d0d0 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 -# Enter solution here \ No newline at end of file +# Enter solution here +def create_3d_array(): + n = 3**3 + array = np.array(range(n)).reshape((3,3,3)) + return array +create_3d_array() + + diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..8d88351 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,14 @@ +# %load q06_get_unique_matches_count/build.py # Default imports +import numpy as np 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') + ipl_matches_array = np.unique(ipl_matches_array[1:,1]) + return len(ipl_matches_array) +get_unique_matches_count() + + diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..b99e2ac 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,13 @@ +# %load q07_get_unique_teams_set/build.py # Default imports +import numpy as np 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(): + array = read_ipl_data_csv(path, dtype = '|S100') + return set(np.unique(array[:, 3:5])) +get_unique_teams_set() + + diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..bb92c7f 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(): + array = read_ipl_data_csv(path,dtype = '|S50') + sum = np.array(array[:,17:18],dtype = int).sum() + return sum +get_total_extras() + +