From a657181c1ffc042f8c16b66e2b6d0cef24f6960a Mon Sep 17 00:00:00 2001 From: ashpandey2509 Date: Sun, 9 Sep 2018 06:42:41 +0000 Subject: [PATCH 1/9] Done --- q01_zeros_array/build.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 + + + From ccd05e775d9ab8eda61462bb704e88f6b59fa801 Mon Sep 17 00:00:00 2001 From: ashpandey2509 Date: Thu, 27 Sep 2018 05:11:58 +0000 Subject: [PATCH 2/9] Done --- q02_zeros_reshaped/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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() + + From bb1da0c739d1a16cccc241a34fd73ecce03e1c00 Mon Sep 17 00:00:00 2001 From: ashpandey2509 Date: Tue, 2 Oct 2018 17:02:17 +0000 Subject: [PATCH 3/9] Done --- q03_create_3d_array/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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() + + + From a98f221b40feb022e9e4a78a62b222f8071a2478 Mon Sep 17 00:00:00 2001 From: ashpandey2509 Date: Tue, 2 Oct 2018 17:34:33 +0000 Subject: [PATCH 4/9] Done --- q04_read_csv_data_to_ndarray/build.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index fb71e6e..0ecb147 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,17 @@ -# 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): + with open(path, 'r') as f: + reader = csv.reader(f, delimiter=',') + # 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 From d5498f518125c3627b04d5ade525df680640538f Mon Sep 17 00:00:00 2001 From: ashpandey2509 Date: Tue, 2 Oct 2018 17:37:30 +0000 Subject: [PATCH 5/9] Done --- q05_read_csv_data/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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') + + From 4b5d794f92dbb82e68964078d04561348d6abda7 Mon Sep 17 00:00:00 2001 From: ashpandey2509 Date: Tue, 2 Oct 2018 17:38:42 +0000 Subject: [PATCH 6/9] Done --- q04_read_csv_data_to_ndarray/build.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index 0ecb147..f617175 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -4,11 +4,9 @@ import matplotlib.pyplot as plt def read_csv_data_to_ndarray(path, dtype): - with open(path, 'r') as f: - reader = csv.reader(f, delimiter=',') - # transform data into numpy array - data = np.genfromtxt(path,dtype, delimiter=',', skip_header=1) - return data + # 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) From e20c06f385aaa18fe6574b1848965adf1b693645 Mon Sep 17 00:00:00 2001 From: ashpandey2509 Date: Fri, 5 Oct 2018 16:42:59 +0000 Subject: [PATCH 7/9] Done --- q06_get_unique_matches_count/build.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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() + + + From 28f1a3ed16c332c71849ce9763d765d398430820 Mon Sep 17 00:00:00 2001 From: ashpandey2509 Date: Sat, 6 Oct 2018 11:26:06 +0000 Subject: [PATCH 8/9] Done --- q07_get_unique_teams_set/build.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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() + + + From 7d5941e38ff767334d640715838319f9f957bc16 Mon Sep 17 00:00:00 2001 From: ashpandey2509 Date: Sat, 6 Oct 2018 11:41:40 +0000 Subject: [PATCH 9/9] Done --- q08_get_total_extras/build.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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() + +