diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..df4c798 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,13 @@ -# Default Imports -import sys, os -sys.path.append(os.path.join(os.path.dirname(os.curdir), '..' )) +#%load q01_zeros_array/build.py + +# import numpy as np +def array_zeros(): + #import numpy as np + + arr=np.zeros((3,4,2)) + return arr + #print(arr) -# Your solution diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..cbbf4dc 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,11 @@ -# Default imports +#%load q02_zeros_reshaped/build.py import numpy as np -from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros +def array_reshaped_zeros(): + + arr=np.zeros((3,4,2)) + zeros_array_reshaped=arr.reshape((2,3,4)) + #print(arr1) + return zeros_array_reshaped + + -# Write your code diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..8ab3b29 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,12 @@ -# Default Imports +#%load q03_create_3d_array/build.py + import numpy as np -# Enter solution here \ No newline at end of file +def create_3d_array() : + + + arr=np.arange(27).reshape(3,3,3) + + return arr + + diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index fb71e6e..935de8d 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,20 @@ -# Default Imports +#%load q04_read_csv_data_to_ndarray/build.py + 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' +dtype= '|S20' +def read_csv_data_to_ndarray(path,dtype): + + arr=np.genfromtxt(path,delimiter=',',dtype=dtype,skip_header=1) +#print(type(arr)) +#print(arr.dtype) + + + return arr + +read_csv_data_to_ndarray(path,dtype) + + + + diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..df26953 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,16 @@ -# Default imports +#%load q05_read_csv_data/build.py + import numpy as np -# Enter code here \ No newline at end of file +path='./data/ipl_matches_small.csv' +dtype='|S50' + +def read_ipl_data_csv(path,dtype): + + ipl_matches_array=np.genfromtxt(path,delimiter=',',skip_header=1,dtype=dtype) + +#print(ipl_matches_array) + return ipl_matches_array + + + diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..068eed2 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,22 @@ -# Default imports -from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv -path = 'data/ipl_matches_small.csv' +#%load q06_get_unique_matches_count/build.py + +import numpy as np + +path='./data/ipl_matches_small.csv' + +def get_unique_matches_count(): + + ipl_matches_array=np.genfromtxt(path,delimiter=',',skip_header=1,dtype='|S20') +#print(ipl_matches_array) + + nouniquecounts=np.unique(ipl_matches_array[:,0],axis=0) + nocounts=nouniquecounts.size + + +#print(noCounts.size) + return nocounts + + + + -# Enter Code Here diff --git a/q07_get_unique_teams_set/build.py b/q07_get_unique_teams_set/build.py index 17fefd2..9d4c837 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,35 @@ -# Default imports -from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv -path = "data/ipl_matches_small.csv" +#%load q07_get_unique_teams_set/build.py/ + +import numpy as np + +path='./data/ipl_matches_small.csv' + +def get_unique_teams_set(): + arr=np.genfromtxt(path,delimiter=',',skip_header=1,dtype='|S25') + + #team1=arr[:,2:] + + team1=np.unique(arr[:,3],axis=0) + team2=np.unique(arr[:,4],axis=0) + + uniqueteams=np.union1d(team1,team2) + #Team=team1.union(team2) + x=set(uniqueteams.flat) + +#print(team1) +#print(team2) +#print(uniqueteams) + return (x) + + + +get_unique_teams_set() + + + + + + + + -# Enter Code Here diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..e7302ab 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,17 @@ -# Default Imports -from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv +#%load q08_get_total_extras/build.py + import numpy as np -path = 'data/ipl_matches_small.csv' +path='./data/ipl_matches_small.csv' + +def get_total_extras(): + + arr=np.genfromtxt(path,delimiter=',',skip_header=1,dtype=int) +#arr + #print(sum(arr[:,17])) + ext=sum(arr[:,17]) + return ext + +get_total_extras() + -# Enter Code Here \ No newline at end of file