From c39f675ef2477d09352c8268ba0028e6f1eed381 Mon Sep 17 00:00:00 2001 From: Hegde51 Date: Tue, 26 Jun 2018 17:11:34 +0000 Subject: [PATCH 1/5] Done --- q01_read_data/build.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..2e7b27fb 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,15 @@ +# %load q01_read_data/build.py import yaml - def read_data(): - # import the csv file into `data` variable + # import the csv file into variable # You can use this path to access the CSV file: '../data/ipl_match.yaml' # Write your code here - - data = + + data = yaml.safe_load(open('./data/ipl_match.yaml')) # return data variable return data + +read_data() + From 56eb38e5ca2b099cfded4132da51020ac69620ac Mon Sep 17 00:00:00 2001 From: Hegde51 Date: Tue, 26 Jun 2018 19:35:14 +0000 Subject: [PATCH 2/5] Done --- q02_teams/build.py | 10 ++++++++-- q03_first_batsman/build.py | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..57b36da7 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -1,11 +1,17 @@ +# %load q02_teams/build.py # default imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() # solution -def teams(data=data): +def teams(data): # write your code here - #teams = + print(data['info']['teams']) return teams + +teams(data) + + + diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..b42e60f3 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -1,13 +1,16 @@ +# %load q03_first_batsman/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() # Your Solution def first_batsman(data=data): + name=data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] # Write your code here - return name +first_batsman(data) + From 227637d14f621248da2bc1be868a26b5d0b687f4 Mon Sep 17 00:00:00 2001 From: Hegde51 Date: Wed, 27 Jun 2018 16:26:12 +0000 Subject: [PATCH 3/5] Done --- q02_teams/build.py | 12 ++++++------ q04_count/build.py | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 57b36da7..5380d68a 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -4,14 +4,14 @@ data = read_data() # solution -def teams(data): +lst = [] +def teams(data): + lst.append(data['info']['teams']) # write your code here - print(data['info']['teams']) - - return teams + + return lst[0] teams(data) - - +lst[0] diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..533657f1 100644 --- a/q04_count/build.py +++ b/q04_count/build.py @@ -1,11 +1,24 @@ +# %load q04_count/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() # Your Solution Here +lst=[] + def deliveries_count(data=data): + lst.append(data['innings'][0]['1st innings']['deliveries']) + # Your code here - + count = 0 + for balls in lst: + if {'batsman': 'RT Ponting'}: + count += 1 + else: + continue + return balls + +deliveries_count(data) +data['innings'][0]['1st innings']['deliveries'] - return count From 851c754e94c5df71832f8660357fb9c0b7c65a07 Mon Sep 17 00:00:00 2001 From: Hegde51 Date: Thu, 12 Jul 2018 17:28:51 +0000 Subject: [PATCH 4/5] Done --- q04_count/build.py | 25 +++++++++++++++---------- q05_runs/build.py | 13 +++++++++++-- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/q04_count/build.py b/q04_count/build.py index 533657f1..ab7859b7 100644 --- a/q04_count/build.py +++ b/q04_count/build.py @@ -4,21 +4,26 @@ data = read_data() # Your Solution Here -lst=[] def deliveries_count(data=data): - lst.append(data['innings'][0]['1st innings']['deliveries']) + count=0 + deliveries = data['innings'][0]['1st innings']['deliveries'] + b = 0.1 + for a in range(len(deliveries)): + for b in deliveries[a]: + print(deliveries[a][b]['batsman']) + if (deliveries[a][b]['batsman']=='RT Ponting'): + count+=1 + return count + # Your code here - count = 0 - for balls in lst: - if {'batsman': 'RT Ponting'}: - count += 1 - else: - continue - return balls + deliveries_count(data) -data['innings'][0]['1st innings']['deliveries'] +#lst[0][46][7.3]['batsman'] +#list(range(lst[0][1],lst[0][123])) +#data['innings'][0]['1st innings']['deliveries'] +current_deliveries diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..ef4affc8 100644 --- a/q05_runs/build.py +++ b/q05_runs/build.py @@ -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() @@ -5,8 +6,16 @@ # Your Solution def BC_runs(data): - + # Write your code here - + runs=0 + data1=data['innings'][0]['1st innings']['deliveries'] + for i in data1: + data2=list(i.values()) + if data2[0]['batsman']=='BB McCullum': + if data2[0]['runs']['batsman']>0: + runs=runs+data2[0]['runs']['batsman'] return(runs) +BC_runs(data) + From 2e80f8519c951ef35b0cd9a416f516fb0c91bd4e Mon Sep 17 00:00:00 2001 From: Hegde51 Date: Thu, 12 Jul 2018 19:44:02 +0000 Subject: [PATCH 5/5] Done --- q06_bowled_players/build.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..66f89877 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -1,11 +1,23 @@ +# %load q06_bowled_players/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() # Your Solution def bowled_out(data=data): - + bowled_players = [] # Write your code here + delivery = data['innings'][1]['2nd innings']['deliveries'] + for balls in delivery: + data1 = list(balls.values()) + if 'wicket' in data1[0].keys(): + if data1[0]['wicket']['kind']=='bowled': + bowled_players.append(data1[0]['batsman']) + return bowled_players + +bowled_out(data) + + + - return bowled_players