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 + + 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 + + + + 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..50abf99 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,14 @@ +# %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=path, input_dtype = np.float64): + from numpy import genfromtxt + return np.genfromtxt(path, delimiter=',', dtype = input_dtype, skip_header=1) +# Enter code here + + + + + 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 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 + + + 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() + + +