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
2 changes: 1 addition & 1 deletion data/ipl_match.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1941,4 +1941,4 @@ innings:
fielders:
- BB McCullum
kind: caught
player_out: SB Joshi
player_out: SB Joshi
4 changes: 2 additions & 2 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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') as f:
data = yaml.load(f)

# return data variable
return data
7 changes: 1 addition & 6 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# default imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# solution
def teams(data=data):

# write your code here
#teams =

teams = data['info']['teams']
return teams
2 changes: 1 addition & 1 deletion q03_first_batsman/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def first_batsman(data=data):

# Write your code here

name=data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']



Expand Down
23 changes: 21 additions & 2 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# %load q04_count/build.py
# Default Imports
import yaml
import json
import pandas as pd
from pandas.io.json import json_normalize
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
# with open(data, 'r') as f:
# df = pd.io.json.json_normalize(yaml.load(f))

# print(df.head())
# Your Solution Here
def deliveries_count(data=data):

# Your code here


count=0
s='SC Ganguly'
name=data['innings'][0]['1st innings']['deliveries']
# b1=name[0][0.1]['batsman']
# df=pd.DataFrame
# df=name
# print(df)
for delivery in name:
for delivery_number,delivery_info in delivery.items():
if delivery_info['batsman']=='RT Ponting':
count+=1
return count
deliveries_count(data)

11 changes: 11 additions & 0 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# %load q05_runs/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()


# Your Solution
def BC_runs(data):
runs=0
name=data['innings'][0]['1st innings']['deliveries']
for delivery in name:
for delivery_number,delivery_info in delivery.items():
if delivery_info['batsman']=='BB McCullum':
run1=delivery_info['runs']
runs+=run1['batsman']

# Write your code here


return(runs)

BC_runs(data)

21 changes: 20 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,24 @@
def bowled_out(data=data):

# Write your code here
bowled_players=[]
wickets=[]
name=data['innings'][1]['2nd innings']['deliveries']
for delivery in name:
for delivery_number,delivery_info in delivery.items():
if 'wicket' in delivery_info:
ab=delivery.items()
for anum,ainfo in ab:
wickets.append(ainfo['wicket'])
# for wnumber,winfo in wickets:
# print(winfo)
# if winfo['kind']=='bowled':
# bowled_players.append(winfo['batsman'])
print(wickets)
for i in range(len(wickets)):
if wickets[i]['kind'] == 'bowled':
bowled_players.append(wickets[i]['player_out'])
return bowled_players
bowled_out(data)


return bowled_players
18 changes: 13 additions & 5 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# Your Solution
def extras_runs(data=data):

# Write your code here
first_innings_deliveries = data['innings'][0]['1st innings']['deliveries']
extras_1st_innings = [delivery_info
for delivery in first_innings_deliveries
for delivery_number, delivery_info in delivery.items()
if 'extras' in delivery_info]
print(len(extras_1st_innings))

second_innings_deliveries = data['innings'][1]['2nd innings']['deliveries']
extras_2nd_innings = [delivery_info
for delivery in second_innings_deliveries
for delivery_number, delivery_info in delivery.items()
if 'extras' in delivery_info]
print(len(extras_2nd_innings))

difference =

difference = len(extras_2nd_innings) - len(extras_1st_innings)

return difference