From fd90222f229e8eda31c2e493b695e8c1d0f37b43 Mon Sep 17 00:00:00 2001 From: Lavi1920 Date: Sun, 2 Sep 2018 15:45:33 +0000 Subject: [PATCH 1/5] Done --- q01_read_data/build.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..3f249342 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,18 @@ +# %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 = + file_path= './data/ipl_match.yaml' + with open(file_path, 'r') as f: + data = yaml.load(f) # return data variable return data + + + + + + + + From f83aea2073002f607a6e0d620143a827895cc87e Mon Sep 17 00:00:00 2001 From: Lavi1920 Date: Mon, 3 Sep 2018 19:15:22 +0000 Subject: [PATCH 2/5] Done --- q02_teams/build.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..665c8d66 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -1,11 +1,24 @@ +# %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 = data): + y=list(data['info']['teams']) + return y + +#f_list=list(data.values(['info'] ['teams'])) +#print(f_list) +#print (x) + + +teams() + + + + + + - # write your code here - #teams = - return teams From 26efeccc35d0e9c020e914e6908a7080a965e9dd Mon Sep 17 00:00:00 2001 From: Lavi1920 Date: Tue, 4 Sep 2018 16:11:03 +0000 Subject: [PATCH 3/5] Done --- q03_first_batsman/build.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..d3b2d91a 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -1,13 +1,15 @@ +# %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 + # Write your code here def first_batsman(data=data): + x=data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] + return x - # Write your code here +first_batsman() + # return name - return name From d700b98a67807d1380d42be8b30a6e8636ac1b63 Mon Sep 17 00:00:00 2001 From: Lavi1920 Date: Sun, 4 Nov 2018 14:01:55 +0000 Subject: [PATCH 4/5] Done --- q04_count/build.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..65207500 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,15 @@ def deliveries_count(data=data): # Your code here - - + total_balls = len(data['innings'][0]['1st innings']['deliveries']) + count = 0 + for i in range(0,total_balls): + key = next(iter(data['innings'][0]['1st innings']['deliveries'][i])) + if data['innings'][0]['1st innings']['deliveries'][i][key]['batsman']=='RT Ponting': + count = count+1 return count + +deliveries_count(data=data) + + + From 66f8b014e160c41caec642445b887199f1ccc76a Mon Sep 17 00:00:00 2001 From: Lavi1920 Date: Mon, 5 Nov 2018 14:30:14 +0000 Subject: [PATCH 5/5] Done --- q05_runs/build.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..52225a21 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,18 @@ # Your Solution def BC_runs(data): + total_balls = len(data['innings'][0]['1st innings']['deliveries']) + runs = 0 + for i in range(0,total_balls): + + key = next(iter(data['innings'][0]['1st innings']['deliveries'][i])) + + if data['innings'][0]['1st innings']['deliveries'][i][key]['batsman']=='BB McCullum': + runs = runs + data['innings'][0]['1st innings']['deliveries'][i][key]['runs']['batsman'] + + return runs + +BC_runs(data) - # Write your code here - return(runs)