diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..2d08e60 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,15 @@ +# %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() diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..f5ade30 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,13 @@ +# %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 = array_zeros() + reshaped_array = np.reshape(zeros_array, (2,3,4)) + return reshaped_array +array_reshaped_zeros() + + diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..f11dc4e 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,13 @@ +# %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(): + one_dim_array = np.array(list(range(0,27))) + three_dim_array = np.reshape(one_dim_array, (3,3,3)) + return three_dim_array + +create_3d_array() + + diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index fb71e6e..5702536 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,16 @@ +# %load q04_read_csv_data_to_ndarray/build.py # Default Imports import numpy as np -path = "./data/ipl_matches_small.csv" +import pandas as pd + + + +path = './data/ipl_matches_small.csv' + +# Enter code here +def read_csv_data_to_ndarray(path, dtype = 'Float64'): + arr = np.genfromtxt('data/ipl_matches_small.csv', dtype=dtype, skip_header=1, delimiter=',') + return arr +read_csv_data_to_ndarray(path) + -# Enter code here \ No newline at end of file diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..24ca46a 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,10 @@ +# %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 = 'Float64'): + ipl_matches_array = np.genfromtxt(path, dtype=dtype, skip_header=1, delimiter=',') + return ipl_matches_array + + diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..eff2d09 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' # Enter Code Here +def get_unique_matches_count(): + ipl_matches_array = read_ipl_data_csv(path, 'U25') + ipl_matches_array = ipl_matches_array[:,0] + count = len(np.unique(ipl_matches_array, axis=0)) + return count +import numpy as np +np.set_printoptions(threshold=np.inf) +get_unique_matches_count() + +