From 303aecd50450060b6fa1c8262d6fc28eb765f773 Mon Sep 17 00:00:00 2001 From: HarnoorSinghA Date: Sat, 8 Sep 2018 11:18:42 +0000 Subject: [PATCH 1/6] Done --- q01_read_data/build.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..8fd82cc8 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,21 @@ +# %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 = + path='./data/ipl_match.yaml' + iplfile=open(path,'r') + + data =yaml.load(iplfile) + # return data variable return data + +read_data() + + + From 52c67887c4c1c741bb64da16238358bf22073e2a Mon Sep 17 00:00:00 2001 From: HarnoorSinghA Date: Sat, 8 Sep 2018 11:51:33 +0000 Subject: [PATCH 2/6] Done --- q02_teams/build.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..be482378 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -1,11 +1,16 @@ +# %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): + info=data.get('info') + # write your code here - #teams = + teams =info.get('teams') return teams + + + From 83dec6d03482e8e977bd3beaaf4338c0099ce2d2 Mon Sep 17 00:00:00 2001 From: HarnoorSinghA Date: Sat, 8 Sep 2018 12:30:59 +0000 Subject: [PATCH 3/6] Done --- q03_first_batsman/build.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..0c1d1857 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -1,9 +1,19 @@ +# %load q03_first_batsman/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() +#ing=data.get('innings') +#firsting=ing[0] +#print(firsting.get('1st innings').get('deliveries')[0].get(0.1).get('batsman')) + + +#print(ing) # Your Solution def first_batsman(data=data): + ing=data.get('innings') + firsting=ing[0] + name=firsting.get('1st innings').get('deliveries')[0].get(0.1).get('batsman') # Write your code here @@ -11,3 +21,7 @@ def first_batsman(data=data): return name + +first_batsman(data) + + From 3c29a767f8259568a99a22235620f4007c0cf27b Mon Sep 17 00:00:00 2001 From: HarnoorSinghA Date: Sat, 8 Sep 2018 13:05:48 +0000 Subject: [PATCH 4/6] Done --- q04_count/build.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..53d05595 100644 --- a/q04_count/build.py +++ b/q04_count/build.py @@ -1,11 +1,25 @@ +# %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 def deliveries_count(data=data): - + ing=data.get('innings') + firsting=ing[0] + fingdict=firsting.get('1st innings') + deliveries=fingdict.get('deliveries') + count=0 + for ball in deliveries: + bat=list(ball.values()) + if bat[0].get('batsman')=='RT Ponting': + count=count+1 + # Your code here return count + +deliveries_count(data) + + From 272f75360c062d9b461889169b688de685a16109 Mon Sep 17 00:00:00 2001 From: HarnoorSinghA Date: Sat, 8 Sep 2018 13:28:49 +0000 Subject: [PATCH 5/6] Done --- q05_runs/build.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..fd730720 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,21 @@ # Your Solution def BC_runs(data): + ing=data.get('innings') + firsting=ing[0] + fingdict=firsting.get('1st innings') + deliveries=fingdict.get('deliveries') + runs=0 + for ball in deliveries: + bat=list(ball.values()) + if bat[0].get('batsman')=='BB McCullum': + run=bat[0].get('runs').get('batsman') + runs=runs+run # Write your code here return(runs) + +BC_runs(data) + From d0f85df2c24ad791441b4ed039c4ccfa42d47aa0 Mon Sep 17 00:00:00 2001 From: HarnoorSinghA Date: Sat, 8 Sep 2018 14:08:13 +0000 Subject: [PATCH 6/6] Done --- q06_bowled_players/build.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..a3c87c31 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -1,11 +1,30 @@ +# %load q06_bowled_players/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() +bowled_players=[] # Your Solution def bowled_out(data=data): + #bowled_players=[] + ing=data.get('innings') + firsting=ing[1] + fingdict=firsting.get('2nd innings') + deliveries=fingdict.get('deliveries') + for ball in deliveries: + bat=list(ball.values()) + if ((bat[0].get('wicket'))!=None): + wicket=bat[0].get('wicket') + if(wicket.get('kind')=='bowled'): + player=wicket.get('player_out') + bowled_players.append(player) + # Write your code here return bowled_players + + + +