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
6 changes: 3 additions & 3 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# %load q01_read_data/build.py
import yaml

def read_data():

# import the csv file into `data` variable
# You can use this path to access the CSV file: '../data/ipl_match.yaml'
# Write your code here

data =

with open( './data/ipl_match.yaml', 'r') as stream:
data = yaml.load(stream)
# return data variable
return data
5 changes: 4 additions & 1 deletion q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q02_teams/build.py
# default imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,6 +7,8 @@
def teams(data=data):

# write your code here
#teams =
teams = data['info']['teams']

return teams
r = teams(data)
print r
9 changes: 5 additions & 4 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# %load q03_first_batsman/build.py
# Default Imports
import pandas as pd
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# Your Solution
def first_batsman(data=data):

# Write your code here




name = data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']
return name
r = first_batsman()
print r
14 changes: 11 additions & 3 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# %load q04_count/build.py
# Default Imports
import pandas as pd
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# Your Solution Here
def deliveries_count(data=data):

count = 0
# Your code here


first_inning = data['innings'][0]['1st innings']['deliveries']
#return pd.DataFrame(first_inning)
for each_delivery in first_inning:
for each_ball, each_ball_detail in each_delivery.items():
if each_ball_detail['batsman'] == 'RT Ponting':
count+=1
return count

deliveries_count(data)
9 changes: 8 additions & 1 deletion q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q05_runs/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -7,6 +8,12 @@
def BC_runs(data):

# Write your code here

runs = 0
first_inning = data['innings'][0]['1st innings']['deliveries']
for each_delivery in first_inning:
for each_ball, each_ball_detail in each_delivery.items():
if each_ball_detail['batsman'] == 'BB McCullum':
runs += each_ball_detail['runs']['batsman']

return(runs)
BC_runs(data)
9 changes: 8 additions & 1 deletion q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q06_bowled_players/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,6 +7,12 @@
def bowled_out(data=data):

# Write your code here

bowled_players = []
first_inning = data['innings'][1]['2nd innings']['deliveries']
for each_delivery in first_inning:
for each_ball, each_ball_detail in each_delivery.items():
if each_ball_detail.get('wicket', {}).get('kind') == 'bowled':
bowled_players.append(each_ball_detail['batsman'])

return bowled_players
bowled_out(data)
20 changes: 17 additions & 3 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q07_extras/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,9 +7,22 @@
def extras_runs(data=data):

# Write your code here


difference =
first_extras = 0
first_inning = data['innings'][0]['1st innings']['deliveries']
for each_delivery in first_inning:
for each_ball, each_ball_detail in each_delivery.items():
#print each_ball_detail['runs']['extras']
if each_ball_detail['runs']['extras'] > 0:
first_extras += 1
#print first_extras
second_extras = 0
second_inning = data['innings'][1]['2nd innings']['deliveries']
for each_delivery in second_inning:
for each_ball, each_ball_detail in each_delivery.items():
if each_ball_detail['runs']['extras'] > 0:
second_extras += 1
difference = abs(second_extras - first_extras)


return difference
extras_runs(data)