diff --git a/q01_get_total_deliveries_players/build.py b/q01_get_total_deliveries_players/build.py index 2bc0f30..22a1e89 100644 --- a/q01_get_total_deliveries_players/build.py +++ b/q01_get_total_deliveries_players/build.py @@ -1,7 +1,22 @@ +# %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=0, delimiter=',') # Your Solution +def get_total_deliveries_played(batsman): + + #Storing the column of batsman into a separate list + batsman_list = ipl_matches_array[1:,13] + + #Returning the count + return np.count_nonzero(batsman_list==batsman) + +#Call to the function. +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..f43d178 100644 --- a/q02_get_wicket_delivery_numbers_array/build.py +++ b/q02_get_wicket_delivery_numbers_array/build.py @@ -1,7 +1,25 @@ +# %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=',') #Your Solution +def get_wicket_delivery_numbers_array(player): + + # We'll make use of boolean indexing to fetch the desired result. + # batsman_out would store all the row values which have to be fetched. + batsman_out = ipl_matches_array[:,-3]==player + + #As we have to fetch the delivery, we put 11 in the coulmn and batsman_out in row. + return ipl_matches_array[batsman_out,11] + + +#Call to the function - +get_wicket_delivery_numbers_array(b'SR Tendulkar') + + + + + diff --git a/q03_get_toss_win_count/build.py b/q03_get_toss_win_count/build.py index d0f09a9..4454489 100644 --- a/q03_get_toss_win_count/build.py +++ b/q03_get_toss_win_count/build.py @@ -1,7 +1,24 @@ +# %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=0, delimiter=',') #Your Solution +def get_toss_win_count(team): + + #Boolean indexing to store toss wins for MI. + MI_TossWin = ipl_matches_array[:,5]==team + + #getting unique toss wins based on match id as the value gets repeated per delivery. + unique_win_count = np.unique(ipl_matches_array[MI_TossWin,0]) + + #returning the count. + return np.count_nonzero(unique_win_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..2924456 100644 --- a/q04_get_all_sixes_filter/build.py +++ b/q04_get_all_sixes_filter/build.py @@ -1,7 +1,16 @@ +# %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(): + #Returning boolean index array where element value for runs is 6. + return ipl_matches_array[:,-7]==b'6' + +#Call to the function +get_all_sixes_filter() + + diff --git a/q05_create_delivery_series/build.py b/q05_create_delivery_series/build.py index fcc1b8a..4487e3b 100644 --- a/q05_create_delivery_series/build.py +++ b/q05_create_delivery_series/build.py @@ -1,7 +1,20 @@ +# %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(): + + #Pikcing up the column of delivery and passing it to series. + Ser1 = pd.Series(ipl_matches_array[:,11]) + return Ser1 + +#Call to the function +create_delivery_series() + + + diff --git a/q06_create_runs_series/build.py b/q06_create_runs_series/build.py index fcc1b8a..945bf2b 100644 --- a/q06_create_runs_series/build.py +++ b/q06_create_runs_series/build.py @@ -1,7 +1,26 @@ +# %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): + + #Assigning a variable to data and index column. + data = ipl_matches_array[:,16] + index = ipl_matches_array[:,11] + + #Returning the Pandas Series. + return pd.Series(data,index) + +#Call to the function. +create_runs_series(b'392203') + + + + + + +