From 91557bcea261ca3a4ba8b28f78e5e31db66927ef Mon Sep 17 00:00:00 2001 From: akshaylakade Date: Sun, 2 Sep 2018 05:12:18 +0000 Subject: [PATCH 1/8] Done --- myfile.txt | 0 q01_read_data/build.py | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 myfile.txt diff --git a/myfile.txt b/myfile.txt new file mode 100644 index 00000000..e69de29b diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..30e802c5 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 = - + + with open('./data/ipl_match.yaml') as file : + + data = yaml.load(file) + # return data variable return data + +d = read_data() +d + + From 18de434c734f2652b236b9d9454ed40f0594e7e5 Mon Sep 17 00:00:00 2001 From: akshaylakade Date: Sun, 2 Sep 2018 08:59:59 +0000 Subject: [PATCH 2/8] Done --- q02_teams/build.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..c286bfb4 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -1,11 +1,15 @@ +# %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): - # write your code here - #teams = + # write your code here + teams = data['info']['teams'] return teams + + + + From c0bba79f269c0784100e2026dda8892f026fa26d Mon Sep 17 00:00:00 2001 From: akshaylakade Date: Tue, 4 Sep 2018 08:56:49 +0000 Subject: [PATCH 3/8] Done --- q03_first_batsman/build.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..3d3a2ce0 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,16 @@ def first_batsman(data=data): # Write your code here - + + name = data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] return name + + + + + + + From 6e51a12c2d04d5d313f4a62d2c1b074e13c401b1 Mon Sep 17 00:00:00 2001 From: akshaylakade Date: Tue, 4 Sep 2018 09:00:28 +0000 Subject: [PATCH 4/8] Done --- q04_count/build.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..b43bfda3 100644 --- a/q04_count/build.py +++ b/q04_count/build.py @@ -1,11 +1,19 @@ +# %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): + i=0 + deliveries = data['innings'][0]['1st innings']['deliveries'] + for delivery in deliveries: + for delivery_number, delivery_info in delivery.items(): + if delivery_info['batsman'] == 'RT Ponting': + i += 1 - # Your code here - - return count + return i + + + From ad6fbd2e39aa60c9b8e6a3951fc546f818add88e Mon Sep 17 00:00:00 2001 From: akshaylakade Date: Fri, 7 Sep 2018 05:54:37 +0000 Subject: [PATCH 5/8] Done --- q05_runs/build.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..474e2bf1 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() @@ -7,6 +8,16 @@ def BC_runs(data): # Write your code here + deliveries = data['innings'][0]['1st innings']['deliveries'] + + runs = 0 + + for i in deliveries: + for key in i: + run_var = i[key] + if run_var['batsman'] == 'BB McCullum': + runs += run_var['runs']['batsman'] + + return(runs) - return(runs) From 59e1a6b99cf670ba7c76b15850e6f2371ea91326 Mon Sep 17 00:00:00 2001 From: akshaylakade Date: Fri, 7 Sep 2018 05:57:06 +0000 Subject: [PATCH 6/8] Done --- q05_runs/build.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/q05_runs/build.py b/q05_runs/build.py index 474e2bf1..2971cfbc 100644 --- a/q05_runs/build.py +++ b/q05_runs/build.py @@ -20,4 +20,7 @@ def BC_runs(data): return(runs) +b = BC_runs(data) +b + From b10eedea49f2538e4b9c97d5d661014d06d70f2a Mon Sep 17 00:00:00 2001 From: akshaylakade Date: Fri, 7 Sep 2018 06:50:39 +0000 Subject: [PATCH 7/8] Done --- q06_bowled_players/build.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..94759bb0 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -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() @@ -6,6 +7,39 @@ def bowled_out(data=data): # Write your code here + bowled_players = [] + + return bowled_players + +# %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): + + # Write your code here + bowled_players = [] + deliveries = data['innings'][1]['2nd innings']['deliveries'] + + for delivery in deliveries: + + for key in delivery: + + run_variable = delivery[key] + + if 'wicket' in run_variable and run_variable['wicket']['kind'] == 'bowled': + + bowled_players.append(run_variable['batsman']) + + + + + return bowled_players + + + From edb5281b0b3a4ce8eda97df39a6acff62d14c0e6 Mon Sep 17 00:00:00 2001 From: akshaylakade Date: Fri, 7 Sep 2018 07:36:39 +0000 Subject: [PATCH 8/8] Done --- q07_extras/build.py | 59 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/q07_extras/build.py b/q07_extras/build.py index cdeb803b..39a9155e 100644 --- a/q07_extras/build.py +++ b/q07_extras/build.py @@ -1,3 +1,34 @@ +from greyatomlib.python_getting_started.q01_read_data.build import read_data +data = read_data() + +def extras_runs(data=data): + deliveries1 = data['innings'][0]['1st innings']['deliveries'] + extras1=[] + + for delivery1 in deliveries1: + + for key in delivery1: + + extras1.append(delivery1[key]['runs']['extras']) + + deliveries2 = data['innings'][1]['2nd innings']['deliveries'] + + extras2=[] + + for delivery2 in deliveries2: + + for key in delivery2: + + extras2.append(delivery2[key]['runs']['extras']) + + difference=sum(extras2)-sum(extras1) + + return difference + +e = extras_runs(data=data) +e + +# %load q07_extras/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() @@ -6,9 +37,35 @@ def extras_runs(data=data): # Write your code here + first_innings = 0 + deliveries1 = data['innings'][0]['1st innings']['deliveries'] + + for i in deliveries1: + for key in i: + run_var = i[key] + if 'extras' in run_var: + for key1 in run_var['extras']: + first_innings += 1 + - difference = + second_innings = 0 + deliveries2 = data['innings'][1]['2nd innings']['deliveries'] + for i in deliveries2: + for key in i: + run_var = i[key] + if 'extras' in run_var: + for key2 in run_var['extras']: + second_innings += 1 + + + difference = (second_innings - first_innings) + return difference + +extras_runs(data=data) + + +