From ed0b7ab8b935fff6170856ccaee0190b31cbb0b5 Mon Sep 17 00:00:00 2001 From: ashit97 Date: Sun, 9 Sep 2018 08:27:10 +0000 Subject: [PATCH 1/6] Done --- q01_read_data/build.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..66d1c9bd 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,20 @@ +# %load q01_read_data/build.py import yaml def read_data(): - - # import the csv file into `data` variable + file_path='./data/ipl_match.yaml' + with open(file_path,'r')as f: + + # 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.load(f) # return data variable return data + +#read_data() + + + From 5649273d80c8c938f68ee18deb078acf35c8dcb0 Mon Sep 17 00:00:00 2001 From: ashit97 Date: Sun, 7 Oct 2018 04:28:56 +0000 Subject: [PATCH 2/6] 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..692c3307 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): + file_path='../data/ipl_match.yaml' + data=['info','teams'] # write your code here - #teams = + teams = 'info','teams' + t1={'kkr'} + t2={'rcb'} + teams=['Royal Challengers Bangalore', 'Kolkata Knight Riders'] + return(teams) + +data['info']['teams'] + + +teams('../data/ipl_match.yaml') + + + - return teams From 0dbe31a2fedcec9b74a6d90c0d1708a00dd1c70b Mon Sep 17 00:00:00 2001 From: ashit97 Date: Sun, 7 Oct 2018 10:44:16 +0000 Subject: [PATCH 3/6] Done --- q03_first_batsman/build.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..8a11dd37 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -1,13 +1,18 @@ +# %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): +def first_batsman(data): - # Write your code here + # Write your code here + ash=data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] + + return ash + +data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] - return name From da3203dd0bf3256c0fc12575b575a9bce9fd9458 Mon Sep 17 00:00:00 2001 From: ashit97 Date: Sat, 24 Nov 2018 10:54:44 +0000 Subject: [PATCH 4/6] Done --- q04_count/build.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..ed078ad2 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,16 @@ def deliveries_count(data=data): # Your code here - - + count= 0 + p=data['innings'][0]['1st innings']['deliveries'] + for a in p: + for b in a: + if(a[b]['batsman'])=='RT Ponting': + count=count+1 return count + +print(deliveries_count) +deliveries_count(data) + + + From a8bac1e6e853cbc54f0d0e4bf06d028453f76799 Mon Sep 17 00:00:00 2001 From: ashit97 Date: Sat, 24 Nov 2018 11:58:19 +0000 Subject: [PATCH 5/6] Done --- q05_runs/build.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..76b7c02c 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,17 @@ def BC_runs(data): # Write your code here - + runs= 0 + p=data['innings'][0]['1st innings']['deliveries'] + for a in p: + for b in a: + if(a[b]['batsman'])=='BB McCullum': + runs+=(a[b]['runs']['batsman']) + return(runs) + +BC_runs(data) + + + From f77d73184de3a0fdaa2b2dfe44feb90f45e4bd1e Mon Sep 17 00:00:00 2001 From: ashit97 Date: Sat, 24 Nov 2018 13:55:25 +0000 Subject: [PATCH 6/6] Done --- q06_bowled_players/build.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..af1a2f23 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,14 @@ def bowled_out(data=data): # Write your code here + bowled_players=[] + for delivery in data['innings'][1]['2nd innings']['deliveries']: + if(delivery[next(iter(delivery))].get('wicket',{}).get('kind',None)=='bowled'): + bowled_players.append(delivery[next(iter(delivery))]['batsman']) + + return bowled_players + +a=bowled_out() +a - return bowled_players