Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion q01_get_total_deliveries_players/build.py
Original file line number Diff line number Diff line change
@@ -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')



13 changes: 12 additions & 1 deletion q02_get_wicket_delivery_numbers_array/build.py
Original file line number Diff line number Diff line change
@@ -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')



14 changes: 13 additions & 1 deletion q03_get_toss_win_count/build.py
Original file line number Diff line number Diff line change
@@ -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')

8 changes: 7 additions & 1 deletion q04_get_all_sixes_filter/build.py
Original file line number Diff line number Diff line change
@@ -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()

13 changes: 12 additions & 1 deletion q05_create_delivery_series/build.py
Original file line number Diff line number Diff line change
@@ -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()

24 changes: 23 additions & 1 deletion q06_create_runs_series/build.py
Original file line number Diff line number Diff line change
@@ -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])