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..202c6a5 100644 --- a/q02_get_wicket_delivery_numbers_array/build.py +++ b/q02_get_wicket_delivery_numbers_array/build.py @@ -1,7 +1,17 @@ +# %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_) + 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(b'ST Jayasuriya') + diff --git a/q03_get_toss_win_count/build.py b/q03_get_toss_win_count/build.py index d0f09a9..fc0b181 100644 --- a/q03_get_toss_win_count/build.py +++ b/q03_get_toss_win_count/build.py @@ -1,7 +1,13 @@ +# %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] + mtch=ipl_matches_array[:,5] + return int(np.count_nonzero(np.unique(indx[(mtch==team)]))) +get_toss_win_count(b'Mumbai Indians') + 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() + 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() + 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') +