From ce271632ec29ac6fbd0adbf09db43316adf7d6af Mon Sep 17 00:00:00 2001 From: sagark93 Date: Thu, 11 Oct 2018 08:48:30 +0000 Subject: [PATCH 1/7] Done --- q01_zeros_array/build.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/q01_zeros_array/build.py b/q01_zeros_array/build.py index 5501f7a..4221518 100644 --- a/q01_zeros_array/build.py +++ b/q01_zeros_array/build.py @@ -1,8 +1,20 @@ +# %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(shape=(3,4,2)) + return zeros_array + + + +var = array_zeros() +var + + + From a2819b1dc2febf2642905522dffea47608e79da6 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Thu, 11 Oct 2018 08:54:16 +0000 Subject: [PATCH 2/7] Done --- q02_zeros_reshaped/build.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/q02_zeros_reshaped/build.py b/q02_zeros_reshaped/build.py index ed629c7..d01ae87 100644 --- a/q02_zeros_reshaped/build.py +++ b/q02_zeros_reshaped/build.py @@ -1,5 +1,14 @@ +# %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 + +zeros_array = array_zeros() +def array_reshaped_zeros(): + zeros_array_reshaped = zeros_array.reshape((2,3,4)) + return zeros_array_reshaped +var = array_reshaped_zeros() +var.shape + From 0a5f8102639acdd4263cfe0538175335860b407d Mon Sep 17 00:00:00 2001 From: sagark93 Date: Thu, 11 Oct 2018 15:28:02 +0000 Subject: [PATCH 3/7] Done --- q03_create_3d_array/build.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/q03_create_3d_array/build.py b/q03_create_3d_array/build.py index 7bb6e2f..6421e12 100644 --- a/q03_create_3d_array/build.py +++ b/q03_create_3d_array/build.py @@ -1,4 +1,31 @@ +# %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(): + + actual = [ + [[0, 1, 2], + [3, 4, 5], + [6, 7, 8]], + + [[9, 10, 11], + [12, 13, 14], + [15, 16, 17]], + + [[18, 19, 20], + [21, 22, 23], + [24, 25, 26]] + ] + var = np.array(actual) +#N = var.size + N = np.count_nonzero(var) + array2 = np.arange(N-1) + var.reshape((3,3,3)) + return var +create_3d_array() + + + + From c92614dd2d7980671f556ba76628552a758e672b Mon Sep 17 00:00:00 2001 From: sagark93 Date: Thu, 11 Oct 2018 15:52:43 +0000 Subject: [PATCH 4/7] Done --- q04_read_csv_data_to_ndarray/build.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/q04_read_csv_data_to_ndarray/build.py b/q04_read_csv_data_to_ndarray/build.py index fb71e6e..5fcdc15 100644 --- a/q04_read_csv_data_to_ndarray/build.py +++ b/q04_read_csv_data_to_ndarray/build.py @@ -1,5 +1,17 @@ +# %load q04_read_csv_data_to_ndarray/build.py # Default Imports import numpy as np -path = "./data/ipl_matches_small.csv" +from numpy import genfromtxt + +path = './data/ipl_matches_small.csv' +input_dtype = '|S100' +# Enter code here +def read_csv_data_to_ndarray(path,input_dtype): + my_data = genfromtxt(path, dtype = input_dtype,delimiter=',',skip_header=1) + np.array(my_data) + return my_data +ipl_array = read_csv_data_to_ndarray('data/ipl_matches_small.csv', input_dtype) + +ipl_array + -# Enter code here \ No newline at end of file From 8b960527082cb8554112800418a0751d89fb53ab Mon Sep 17 00:00:00 2001 From: sagark93 Date: Fri, 12 Oct 2018 05:49:49 +0000 Subject: [PATCH 5/7] Done --- q05_read_csv_data/build.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/q05_read_csv_data/build.py b/q05_read_csv_data/build.py index 5c70e6e..6973e49 100644 --- a/q05_read_csv_data/build.py +++ b/q05_read_csv_data/build.py @@ -1,4 +1,18 @@ +# %load q05_read_csv_data/build.py # Default imports import numpy as np +from numpy import genfromtxt + +# Enter code here +path = './data/ipl_matches_small.csv' +input_dtype = '|S50' +def read_ipl_data_csv(path,dtype): + ipl_matches_array = genfromtxt(path, dtype = dtype,delimiter=',',skip_header=1) + np.array(ipl_matches_array) + return ipl_matches_array + +ipl_matches_array = read_ipl_data_csv('data/ipl_matches_small.csv',input_dtype) + +ipl_matches_array + -# Enter code here \ No newline at end of file From 9c6c5db414203633bdf6ce63ffca865ae081a761 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Wed, 16 Jan 2019 09:45:41 +0000 Subject: [PATCH 6/7] Done --- q08_get_total_extras/build.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/q08_get_total_extras/build.py b/q08_get_total_extras/build.py index 95890c1..b16e62d 100644 --- a/q08_get_total_extras/build.py +++ b/q08_get_total_extras/build.py @@ -1,7 +1,16 @@ +# %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 +import pandas as pd path = 'data/ipl_matches_small.csv' -# Enter Code Here \ No newline at end of file +# Enter Code Here +matches = pd.read_csv(path) +matches['extras'].sum() +def get_total_extras (): + extras = matches['extras'].sum() + return extras +get_total_extras() + From a230940e974a0e08422de8df17fed5040387e2de Mon Sep 17 00:00:00 2001 From: sagark93 Date: Wed, 16 Jan 2019 11:10:00 +0000 Subject: [PATCH 7/7] Done --- q06_get_unique_matches_count/build.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/q06_get_unique_matches_count/build.py b/q06_get_unique_matches_count/build.py index 014497e..8cf1407 100644 --- a/q06_get_unique_matches_count/build.py +++ b/q06_get_unique_matches_count/build.py @@ -1,5 +1,25 @@ +# %load q06_get_unique_matches_count/build.py # Default imports from greyatomlib.python_intermediate.q05_read_csv_data.build import read_ipl_data_csv +#import numpy as np +from numpy import genfromtxt +import pandas as pd path = 'data/ipl_matches_small.csv' # Enter Code Here + +matches = pd.read_csv('data/ipl_matches_small.csv') +#genfromtxt(path,delimiter=',',skip_header=1) +matches.head() +type(matches) +temp = matches['match_code'].nunique() +temp +def get_unique_matches_count(): + # data = genfromtxt(path,delimiter=',',skip_header=1) + # ipl_matches_array = np.unique(data,return_counts = True) + ipl_matches_array = matches['match_code'].nunique() + return ipl_matches_array +get_unique_matches_count() + + +