diff --git a/q01_get_total_deliveries_players/build.py b/q01_get_total_deliveries_players/build.py index 2bc0f30..07d0e55 100644 --- a/q01_get_total_deliveries_players/build.py +++ b/q01_get_total_deliveries_players/build.py @@ -1,7 +1,21 @@ +# %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=b'SR Tendulkar'):#function buileded with default parameter batsman + batsman_total=ipl_matches_array[:,13:14] #accessing the batsman column from the array for the count + batsman_ball_faced=list(batsman_total).count(b'SR Tendulkar') #getting the count of the of the batsman + return(batsman_ball_faced) + +get_total_deliveries_played() + + + + + + + diff --git a/q02_get_wicket_delivery_numbers_array/build.py b/q02_get_wicket_delivery_numbers_array/build.py index 47401a5..b5c30ac 100644 --- a/q02_get_wicket_delivery_numbers_array/build.py +++ b/q02_get_wicket_delivery_numbers_array/build.py @@ -1,7 +1,19 @@ +# %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=0, delimiter=',') + +def get_wicket_delivery_numbers_array(batsman): + delivery = ipl_matches_array[:,11] # delievery column which has to be given in op is considered as main dataset + playerout = ipl_matches_array[:,20]==batsman # [create filter: batsman] accesssing the column playerout + return delivery[playerout] #apply the filter in the main data(deliveries to get the values) + + + + + + + -#Your Solution diff --git a/q03_get_toss_win_count/build.py b/q03_get_toss_win_count/build.py index d0f09a9..722574d 100644 --- a/q03_get_toss_win_count/build.py +++ b/q03_get_toss_win_count/build.py @@ -1,7 +1,22 @@ +# %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): + Toss_win=ipl_matches_array[:,5]==team + + unique_win_count = np.unique(ipl_matches_array[Toss_win,0]) + + return np.count_nonzero(unique_win_count) #returning the count. + +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..c6d0569 100644 --- a/q04_get_all_sixes_filter/build.py +++ b/q04_get_all_sixes_filter/build.py @@ -1,7 +1,17 @@ +# %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(): + six_filter = (ipl_matches_array[:, 16].astype(np.int16) == 6) + return six_filter + +get_all_sixes_filter() + + + + diff --git a/q05_create_delivery_series/build.py b/q05_create_delivery_series/build.py index fcc1b8a..5744314 100644 --- a/q05_create_delivery_series/build.py +++ b/q05_create_delivery_series/build.py @@ -1,7 +1,17 @@ +# %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=",") +ipl_matches_array =np.genfromtxt('data/ipl_matches_small.csv', dtype='|S50', skip_header=1, delimiter=',') #Your Solution +def create_delivery_series(): + series=pd.Series(ipl_matches_array[:,11]) + return series + + +import pandas as pd +pd.Series(ipl_matches_array[:,11]) + + diff --git a/q06_create_runs_series/build.py b/q06_create_runs_series/build.py index fcc1b8a..a15a63a 100644 --- a/q06_create_runs_series/build.py +++ b/q06_create_runs_series/build.py @@ -1,7 +1,15 @@ +# %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): + runs = ipl_matches_array[:,16] + index = ipl_matches_array[:,11] + return pd.Series(runs,index) + + +