diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..878dc15 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,16 @@ -# 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): + zeros_array = np.zeros((3,4,2)) + return zeros_array + +import numpy as np + +def array_zeros(*zeros_array): + zeros_array = np.zeros((3,4,2)) + return zeros_array + + + diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..734042d 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 # Default imports import numpy as np from greyatomlib.python_intermediate.q01_zeros_array.build import array_zeros -# Write your code + +def array_reshaped_zeros(): + ans = array_zeros() + return ans.reshape(2,3,4) +array_reshaped_zeros() + + diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..f79805c 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,11 @@ -# Default Imports + import numpy as np -# Enter solution here \ No newline at end of file +def create_3d_array(): + array = np.arange(27).reshape(3,3,3) + return 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..f617175 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,15 @@ -# Default Imports + +import csv import numpy as np -path = "./data/ipl_matches_small.csv" +import matplotlib.pyplot as plt + +def read_csv_data_to_ndarray(path, dtype): + # transform data into numpy array + data = np.genfromtxt(path,dtype, delimiter=',', skip_header=1) + return data + + +read_csv_data_to_ndarray('data/ipl_matches_small.csv',float) + + -# 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..97fc139 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,11 @@ -# Default imports + import numpy as np -# Enter code here \ No newline at end of file + +def read_ipl_data_csv(path, dtype): + # transform data into numpy array + data = np.genfromtxt(path,dtype, delimiter=',', skip_header=1) + return data +read_ipl_data_csv('data/ipl_matches_small.csv', '|S50') + + diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..8f1289e 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,17 @@ -# 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 (): + unique_list = [] + mylist = read_ipl_data_csv('data/ipl_matches_small.csv', '|S50') + #unique_list =set(x for unique_list in mylist[0] for x in unique_list) + unique_list=set(mylist[:, 0]) + print (unique_list) + ipl_matches_array = len(unique_list) + return 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..6aeadcd 100644 --- a/q07_get_unique_teams_set/build.py +++ b/q07_get_unique_teams_set/build.py @@ -1,5 +1,20 @@ -# Default imports + +import numpy as np +import pandas as pd 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_teams_set(): + team1 = [] + team2 = [] + Total_Teams = [] + mylist = read_ipl_data_csv('data/ipl_matches_small.csv', '|S50') + np.set_printoptions(threshold=np.nan) + team1=list(mylist[:,3]) + team2=list(mylist[:,4]) + Total_Teams = set(team1+team2) + print (Total_Teams) + return Total_Teams +get_unique_teams_set() + + + diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..acfdb84 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,17 @@ +# %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(): + total_extras=0 + mylist = read_ipl_data_csv(path,int) + np.set_printoptions(threshold=np.nan) + total_extras=sum(list(mylist[:, 17])) + return total_extras +get_total_extras() + +