From b0a3abc5a9b53eee875c52c531932efba4cf151d Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Wed, 5 Sep 2018 09:29:29 +0000 Subject: [PATCH 1/7] Done --- q01_read_data/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..e37cf686 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,19 @@ +# %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 = + with open('./data/ipl_match.yaml', 'r') as f: + data=yaml.load(f) + # return data variable return data + + + From ea004863a6f9ffb776309c126b2de2bde8f70e02 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Wed, 5 Sep 2018 09:54:53 +0000 Subject: [PATCH 2/7] Done --- q02_teams/build.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..6173fa72 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -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() @@ -7,5 +8,12 @@ def teams(data=data): # write your code here #teams = + teams=data['info']['teams'] return teams + + + + + + From 4ab4dc2e9d198830bddfc88dd733d41bacb4761f Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Wed, 5 Sep 2018 12:53:53 +0000 Subject: [PATCH 3/7] Done --- q03_first_batsman/build.py | 6 +++++- q04_count/build.py | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..b133bf5f 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -1,3 +1,4 @@ +# %load q03_first_batsman/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() @@ -6,8 +7,11 @@ def first_batsman(data=data): # Write your code here + first_batsman=data['innings'][0]['1st innings']['deliveries'][0]['0.1']['batsman'] + + return first_batsman + - return name diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..237f9fbf 100644 --- a/q04_count/build.py +++ b/q04_count/build.py @@ -1,3 +1,4 @@ +# %load q04_count/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() @@ -6,6 +7,17 @@ def deliveries_count(data=data): # Your code here - + d=data['innings'][0]['1st innings']['deliveries'] + count=0 + for item in d: + for v in item.values(): + for key,values in v.items(): + if key=='batsman': + if values=='RT Ponting': + count=count+1 + return count + + + From 883a9a209e6610ec7ad6e45922067b36051a34af Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Thu, 6 Sep 2018 09:14:15 +0000 Subject: [PATCH 4/7] Done --- q03_first_batsman/build.py | 6 ++---- q05_runs/build.py | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index b133bf5f..dc7c15da 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -7,11 +7,9 @@ def first_batsman(data=data): # Write your code here - first_batsman=data['innings'][0]['1st innings']['deliveries'][0]['0.1']['batsman'] + name=data['innings'][0]['1st innings']['deliveries'][0]['0.1']['batsman'] - - - return first_batsman + return name diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..239c559a 100644 --- a/q05_runs/build.py +++ b/q05_runs/build.py @@ -1,12 +1,17 @@ -# Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() +def BC_runs(data=data): + runs=0 + d=data['innings'][0]['1st innings']['deliveries'] + for i in d: + for v in i.values(): + for key,values in v.items(): + if key=='batsman': + if values=='BB McCullum': + runs=v.get('runs')['batsman']+runs + + return runs + -# Your Solution -def BC_runs(data): - # Write your code here - - - return(runs) From e4ad655e47fd6e7dba3656e786540f85217fc662 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Thu, 6 Sep 2018 16:13:36 +0000 Subject: [PATCH 5/7] Done --- q03_first_batsman/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index dc7c15da..4cbeeb7d 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -7,7 +7,7 @@ def first_batsman(data=data): # Write your code here - name=data['innings'][0]['1st innings']['deliveries'][0]['0.1']['batsman'] + name=data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] return name From bded7940e8b2fc14f4454f0e2162fe37a556bcca Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sat, 15 Sep 2018 10:34:00 +0000 Subject: [PATCH 6/7] Done --- q06_bowled_players/build.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..60453c55 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -1,11 +1,19 @@ -# 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='' + bowled_players=[] + d=data['innings'][1]['2nd innings']['deliveries'] + for index,values in enumerate(d): + for key,val in values.items(): + for key,v in val.items(): + if key=='wicket': + for key,va in v.items(): + if key=='kind': + if va=='bowled': + bowled=v.get('player_out') + bowled_players.append(bowled) + + return bowled_players - # Write your code here - - - return bowled_players From 34c99c73f233b78de3f812ac2776d6915ca3c729 Mon Sep 17 00:00:00 2001 From: sunilhariharan Date: Sat, 15 Sep 2018 11:34:38 +0000 Subject: [PATCH 7/7] Done --- q07_extras/build.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/q07_extras/build.py b/q07_extras/build.py index cdeb803b..5623bd74 100644 --- a/q07_extras/build.py +++ b/q07_extras/build.py @@ -1,14 +1,27 @@ -# 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 - - - difference = - - + + e1=[] + d1=data['innings'][0]['1st innings']['deliveries'] + for index,v in enumerate(d1): + for key,va in v.items(): + for key,val in va.items(): + if key=='extras': + for key,values in val.items(): + e1.append(values) + + e2=[] + d2=data['innings'][1]['2nd innings']['deliveries'] + for index,v in enumerate(d2): + for key,va in v.items(): + for key,val in va.items(): + if key=='extras': + for key,values in val.items(): + e2.append(values) + + difference=len(e2)-len(e1) + return difference +