From 69844cb5b37140d4d1224cf562990cad628f1b9d Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sun, 30 Sep 2018 07:11:34 +0000 Subject: [PATCH 1/6] Done --- q01_get_total_deliveries_players/build.py | 13 ++++++++++++- q02_get_wicket_delivery_numbers_array/build.py | 10 +++++++++- q03_get_toss_win_count/build.py | 9 ++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/q01_get_total_deliveries_players/build.py b/q01_get_total_deliveries_players/build.py index 2bc0f30..ab5d1e3 100644 --- a/q01_get_total_deliveries_players/build.py +++ b/q01_get_total_deliveries_players/build.py @@ -1,7 +1,18 @@ +# %load q01_get_total_deliveries_players/build.py # Default imports import numpy as np -ipl_matches_array =np.genfromtxt("data/ipl_matches_small.csv", dtype="|S50", skip_header=1, delimiter=",") +ipl_matches_array =np.genfromtxt('data/ipl_matches_small.csv', dtype='|S50', skip_header=1, delimiter=',') # Your Solution +def get_total_deliveries_played(batsman): + batcount = 0 + #ptn=ipl_matches_array[:,13].astype(np.unicode_) + ptn=ipl_matches_array[:,13] + batcount = int(np.sum(ptn == batsman)) + return batcount + +get_total_deliveries_played(b'SR Tendulkar') + + diff --git a/q02_get_wicket_delivery_numbers_array/build.py b/q02_get_wicket_delivery_numbers_array/build.py index 47401a5..827a393 100644 --- a/q02_get_wicket_delivery_numbers_array/build.py +++ b/q02_get_wicket_delivery_numbers_array/build.py @@ -1,7 +1,15 @@ +# %load q02_get_wicket_delivery_numbers_array/build.py #Default Imports import numpy as np -ipl_matches_array =np.genfromtxt("data/ipl_matches_small.csv", dtype="|S50", skip_header=1, delimiter=",") +ipl_matches_array =np.genfromtxt('data/ipl_matches_small.csv', dtype='|S50', skip_header=1, delimiter=',') #Your Solution +def get_wicket_delivery_numbers_array(player): + over = ipl_matches_array[:,11].astype(np.unicode_) + btsmn = ipl_matches_array[:,20].astype(np.unicode_) + return over[(btsmn == player)] + +get_wicket_delivery_numbers_array('ST Jayasuriya') + diff --git a/q03_get_toss_win_count/build.py b/q03_get_toss_win_count/build.py index d0f09a9..f7c708d 100644 --- a/q03_get_toss_win_count/build.py +++ b/q03_get_toss_win_count/build.py @@ -1,7 +1,14 @@ +# %load q03_get_toss_win_count/build.py #Default Imports import numpy as np -ipl_matches_array =np.genfromtxt("data/ipl_matches_small.csv", dtype="|S50", skip_header=1, delimiter=",") +ipl_matches_array =np.genfromtxt('data/ipl_matches_small.csv', dtype='|S50', skip_header=1, delimiter=',') #Your Solution +def get_toss_win_count(team): + indx=ipl_matches_array[:,0].astype(np.int64) + mtch=ipl_matches_array[:,5].astype(np.unicode_) + return int(np.count_nonzero(np.unique(indx[(mtch==team)]))) +get_toss_win_count('Mumbai Indians') + From 65c3e3a7add03739fa062f82e5294914aeae9f1c Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sun, 30 Sep 2018 07:14:07 +0000 Subject: [PATCH 2/6] Done --- q02_get_wicket_delivery_numbers_array/build.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/q02_get_wicket_delivery_numbers_array/build.py b/q02_get_wicket_delivery_numbers_array/build.py index 827a393..202c6a5 100644 --- a/q02_get_wicket_delivery_numbers_array/build.py +++ b/q02_get_wicket_delivery_numbers_array/build.py @@ -6,10 +6,12 @@ #Your Solution def get_wicket_delivery_numbers_array(player): - over = ipl_matches_array[:,11].astype(np.unicode_) - btsmn = ipl_matches_array[:,20].astype(np.unicode_) + #over = ipl_matches_array[:,11].astype(np.unicode_) + over = ipl_matches_array[:,11] + #btsmn = ipl_matches_array[:,20].astype(np.unicode_) + btsmn = ipl_matches_array[:,20] return over[(btsmn == player)] -get_wicket_delivery_numbers_array('ST Jayasuriya') +get_wicket_delivery_numbers_array(b'ST Jayasuriya') From cae238a6058a0738effe1d71607078c311e0e9f4 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sun, 30 Sep 2018 07:17:50 +0000 Subject: [PATCH 3/6] Done --- q03_get_toss_win_count/build.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/q03_get_toss_win_count/build.py b/q03_get_toss_win_count/build.py index f7c708d..fc0b181 100644 --- a/q03_get_toss_win_count/build.py +++ b/q03_get_toss_win_count/build.py @@ -3,12 +3,11 @@ import numpy as np ipl_matches_array =np.genfromtxt('data/ipl_matches_small.csv', dtype='|S50', skip_header=1, delimiter=',') - #Your Solution def get_toss_win_count(team): - indx=ipl_matches_array[:,0].astype(np.int64) - mtch=ipl_matches_array[:,5].astype(np.unicode_) + indx=ipl_matches_array[:,0] + mtch=ipl_matches_array[:,5] return int(np.count_nonzero(np.unique(indx[(mtch==team)]))) -get_toss_win_count('Mumbai Indians') +get_toss_win_count(b'Mumbai Indians') From 4ac7ebac4001b31b891cd4bdfeec8538bd34c131 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sun, 30 Sep 2018 08:22:51 +0000 Subject: [PATCH 4/6] Done --- q04_get_all_sixes_filter/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q04_get_all_sixes_filter/build.py b/q04_get_all_sixes_filter/build.py index d0f09a9..73c4374 100644 --- a/q04_get_all_sixes_filter/build.py +++ b/q04_get_all_sixes_filter/build.py @@ -1,7 +1,13 @@ +# %load q04_get_all_sixes_filter/build.py #Default Imports import numpy as np -ipl_matches_array =np.genfromtxt("data/ipl_matches_small.csv", dtype="|S50", skip_header=1, delimiter=",") +ipl_matches_array=np.genfromtxt('data/ipl_matches_small.csv', dtype='|S50', skip_header=1, delimiter=',') #Your Solution +def get_all_sixes_filter(): + return (ipl_matches_array[:,16].astype(int) == 6) + +get_all_sixes_filter() + From e7837f8b6adda033038fe87800e659937b363843 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Tue, 2 Oct 2018 05:24:23 +0000 Subject: [PATCH 5/6] Done --- q05_create_delivery_series/build.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/q05_create_delivery_series/build.py b/q05_create_delivery_series/build.py index fcc1b8a..df67e64 100644 --- a/q05_create_delivery_series/build.py +++ b/q05_create_delivery_series/build.py @@ -1,7 +1,14 @@ +# %load q05_create_delivery_series/build.py #Default Imports -import pandas as pd import numpy as np -ipl_matches_array =np.genfromtxt("data/ipl_matches_small.csv", dtype="|S50", skip_header=1, delimiter=",") - +import pandas as pd +ipl_matches_array=np.genfromtxt('data/ipl_matches_small.csv', dtype='|S50', skip_header=1, delimiter=',') + #Your Solution +def create_delivery_series(): + return pd.Series(ipl_matches_array[:,11]) + + +create_delivery_series() + From 34eaeb8e57e70f2aade7749ce0c471285c3cbc86 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Tue, 2 Oct 2018 06:00:51 +0000 Subject: [PATCH 6/6] Done --- q06_create_runs_series/build.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/q06_create_runs_series/build.py b/q06_create_runs_series/build.py index fcc1b8a..644de99 100644 --- a/q06_create_runs_series/build.py +++ b/q06_create_runs_series/build.py @@ -1,7 +1,14 @@ +# %load q06_create_runs_series/build.py #Default Imports import pandas as pd import numpy as np -ipl_matches_array =np.genfromtxt("data/ipl_matches_small.csv", dtype="|S50", skip_header=1, delimiter=",") +ipl_matches_array =np.genfromtxt('data/ipl_matches_small.csv', dtype='|S50', skip_header=1, delimiter=',') #Your Solution +def create_runs_series(match_code): + blt = ipl_matches_array[(ipl_matches_array[:,0] == match_code)] + return pd.Series(blt[:,11],index=blt[:,16]) + +create_runs_series(b'392203') +