From 8adf034c7c0f2b400f54bd550dd87b93ffd2c83d Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sat, 1 Sep 2018 17:54:18 +0000 Subject: [PATCH 1/7] Done --- q01_read_data/build.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..6b88f2e5 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,17 @@ import yaml def read_data(): + + data1= open('./data/ipl_match.yaml','r') + data=yaml.load(data1) + + + + + return 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 = - # return data variable - return data From e542648ae11c65c63fb38cb1f7b931c91cdcf143 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sat, 1 Sep 2018 18:23:59 +0000 Subject: [PATCH 2/7] Done --- q02_teams/build.py | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..7dc061eb 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -1,11 +1,34 @@ -# default imports -from greyatomlib.python_getting_started.q01_read_data.build import read_data -data = read_data() +#%load q02_teams/build.py + +import yaml + +def teams(data): + data1=open('./data/ipl_match.yaml','r') + data=yaml.load(data1) + + teams1=data['info']['teams'] + + return teams1 + + + + + + + + + + + + + + + + + + + + -# solution -def teams(data=data): - # write your code here - #teams = - return teams From 0be764f9ac6378a7d057c8f5fffba025070321f4 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sat, 1 Sep 2018 18:46:23 +0000 Subject: [PATCH 3/7] Done --- q03_first_batsman/build.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..fd3e8350 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -1,13 +1,20 @@ -# Default Imports -from greyatomlib.python_getting_started.q01_read_data.build import read_data -data = read_data() +#%load q03_first_batsman/build.py + +import yaml + +def first_batsman(d): + data=open('./data/ipl_match.yaml','r') + data1=yaml.load(data) + data2=data1['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] +#data3=data2['1st innings']['deliveries'][0][0.1]['batsman'] +#print(data3) + return data2 + + + -# Your Solution -def first_batsman(data=data): - # Write your code here - return name From f01077baf240ed0349cf30c0e7abd2237d4d566a Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Thu, 6 Sep 2018 06:23:53 +0000 Subject: [PATCH 4/7] Done --- q04_count/build.py | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..c414874c 100644 --- a/q04_count/build.py +++ b/q04_count/build.py @@ -1,11 +1,42 @@ -# Default Imports -from greyatomlib.python_getting_started.q01_read_data.build import read_data -data = read_data() +#%load q04_count/build.py -# Your Solution Here -def deliveries_count(data=data): + +def deliveries_count(data): - # Your code here + import yaml + + data=open('./data/ipl_match.yaml','r') + data1=yaml.load(data) + d=data1['innings'][0]['1st innings']['deliveries'] + + #d1=d + count=0 + for key,value in enumerate(d): + value1=d[key] + #print(value) + #print(key,value,type(value)) + for k,v in value1.items(): + + + #print(v) + if value1[k]['batsman']=='RT Ponting': + + count += 1 return count + + +#deliveries_count(d1) + + + + + + + + + + + + From 8cb8ea38ecd721c7c48f29abb82a8d1029ede9fb Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Thu, 6 Sep 2018 14:41:05 +0000 Subject: [PATCH 5/7] Done --- q05_runs/build.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..011fce52 100644 --- a/q05_runs/build.py +++ b/q05_runs/build.py @@ -1,12 +1,29 @@ +# %load q05_runs/build.py # Default Imports -from greyatomlib.python_getting_started.q01_read_data.build import read_data -data = read_data() - - +#om greyatomlib.python_getting_started.q01_read_data.build import read_data +#ata = read_data() +#rint(data) # Your Solution -def BC_runs(data): +#def BC_runs(data): # Write your code here - return(runs) + #return(runs) +import yaml +def BC_runs(data): + + data=open('./data/ipl_match.yaml','r') + data1=yaml.load(data) + data2=data1['innings'][0]['1st innings']['deliveries'] + runs=0 + for key,value in enumerate(data2): + for k,v in value.items(): + if v['batsman']=='BB McCullum': + runs+=(v['runs']['batsman']) + + + + return runs + + From 8b99ab11cfa80e035825caed0e5380f1efc0b031 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Thu, 6 Sep 2018 19:32:27 +0000 Subject: [PATCH 6/7] Done --- q06_bowled_players/build.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..a160f437 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -1,11 +1,30 @@ -# Default Imports -from greyatomlib.python_getting_started.q01_read_data.build import read_data -data = read_data() +#%load q06_bowled_players/build.py -# Your Solution -def bowled_out(data=data): +import yaml + +def bowled_out(data): + data=open('./data/ipl_match.yaml','r') + data1=yaml.load(data) + data2=data1['innings'][1]['2nd innings']['deliveries'] + bowled_players=[] + for key,value in enumerate(data2): + for k,v in value.items(): + if 'wicket' in v.keys(): + if (v['wicket']['kind'])=='bowled': + bowled_players.append(v['wicket']['player_out']) +#print(bowled_players) + # + + + return (bowled_players) + #print(v.keys()) + #if v.keys() =='wicket':#['wicket']['kind']=='bowled': + #print(v) + + #print(v) + + #print(type(value)) +#print(data2) - # Write your code here - return bowled_players From ca23c900e34725c9c8045da081140380d5e8a0b8 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Thu, 6 Sep 2018 20:11:53 +0000 Subject: [PATCH 7/7] Done --- q07_extras/build.py | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/q07_extras/build.py b/q07_extras/build.py index cdeb803b..d2b9d06a 100644 --- a/q07_extras/build.py +++ b/q07_extras/build.py @@ -1,14 +1,41 @@ -# Default Imports -from greyatomlib.python_getting_started.q01_read_data.build import read_data -data = read_data() +#%load q07_extras/build.py -# Your Solution -def extras_runs(data=data): +import yaml - # Write your code here +def extras_runs(data): + + data=open('./data/ipl_match.yaml','r') + data1=yaml.load(data) + data_2nd=data1['innings'][1]['2nd innings']['deliveries'] + data_1st=data1['innings'][0]['1st innings']['deliveries'] + count1=[] + count2=[] + for key,value in enumerate(data_2nd): + + for k,v in value.items(): + + if v['runs']['extras']>0: + + count2.append(v['runs']['extras']) + + + - difference = - + for key1,value1 in enumerate(data_1st): + + for k1,v1 in value1.items(): + if v1['runs']['extras']>0: + count1.append(v1['runs']['extras']) +#print(len(count1)) + difference=(len(count2)-len(count1)) + return difference + + + + + + +