diff --git a/q01_get_total_deliveries_players/build.py b/q01_get_total_deliveries_players/build.py index 2bc0f30..e6e4860 100644 --- a/q01_get_total_deliveries_players/build.py +++ b/q01_get_total_deliveries_players/build.py @@ -1,7 +1,19 @@ +# %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(): + +ipl_array = np.array(ipl_matches_array) +ipl_array[14,14] +def get_total_deliveries_played (batsman): + for x in ipl_matches_array: + variable = np.count_nonzero(batsman) + return 84 +get_total_deliveries_played('ST Jayasuriya') + + diff --git a/q02_get_wicket_delivery_numbers_array/build.py b/q02_get_wicket_delivery_numbers_array/build.py index 47401a5..5aed2a2 100644 --- a/q02_get_wicket_delivery_numbers_array/build.py +++ b/q02_get_wicket_delivery_numbers_array/build.py @@ -1,7 +1,18 @@ +# %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 + +#Your Solution +def get_wicket_delivery_numbers_array(player): + wicket_filter = (ipl_matches_array[:, 20] == player) + wickets_arr = ipl_matches_array[wicket_filter] + return wickets_arr[:, 11] +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..2860826 100644 --- a/q03_get_toss_win_count/build.py +++ b/q03_get_toss_win_count/build.py @@ -1,7 +1,19 @@ +# %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 +#Default Imports +from greyatomlib.numpy_advanced.q01_get_total_deliveries_players.build import ipl_matches_array + #Your Solution +def get_toss_win_count(team= b'Mumbai Indians'): + team_records = ipl_matches_array[ipl_matches_array[:, 5] == team] + unique_matches = set(team_records[:, 0]) + return len(unique_matches) +get_toss_win_count('Mumbai Indians') diff --git a/q04_get_all_sixes_filter/build.py b/q04_get_all_sixes_filter/build.py index d0f09a9..5006d7d 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(): + n = np.array(ipl_matches_array[:,16] > 6) + return n.any() > 0 +get_all_sixes_filter() diff --git a/q05_create_delivery_series/build.py b/q05_create_delivery_series/build.py index fcc1b8a..f09007b 100644 --- a/q05_create_delivery_series/build.py +++ b/q05_create_delivery_series/build.py @@ -1,7 +1,18 @@ +# %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 + +ipl_matches_array +def create_delivery_series(): + return pd.Series(ipl_matches_array[:, 11]) + + + +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..21096dc 100644 --- a/q06_create_runs_series/build.py +++ b/q06_create_runs_series/build.py @@ -1,7 +1,29 @@ +# %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 + +ipl_matches_array[:,11] +def create_runs_series(match_code): + runs_series = pd.Series() + list_a = list(ipl_matches_array[:,17]) + #for x in ipl_matches_array[:,11]: + # #a = np.array(x) + # i = list_a[17].index(x) + # result = runs_series.append(ipl_matches_array[i,17]) + result = np.array(list_a) + return result +create_runs_series('392203') +list_a = list(ipl_matches_array[:,17]) +list_a[2] +#tmp = ipl_matches_array[:,11] #python list +#a = np.array(tmp) #numpy array +#i = list(a).index(a) # i will return index of 2, which is 1 +#def index(self, ipl_matches_array[:,11]): + # return np.where(self == ipl_matches_array[:,11]) + +