Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit Live PR #198

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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
17 changes: 16 additions & 1 deletion q01_get_total_deliveries_players/build.py
Original file line number Diff line number Diff line change
@@ -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')





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






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





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



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




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