From 8fe9896f01630147d83194cd934c1ffef026704f Mon Sep 17 00:00:00 2001 From: avnishxlr8 Date: Sun, 21 Oct 2018 10:36:57 +0000 Subject: [PATCH 1/4] Done --- q01_plot_deliveries_by_team/build.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..215e93c 100644 --- a/q01_plot_deliveries_by_team/build.py +++ b/q01_plot_deliveries_by_team/build.py @@ -1,3 +1,4 @@ +# %load q01_plot_deliveries_by_team/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt @@ -5,5 +6,19 @@ ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) +def plot_deliveries_by_team(): + x = ipl_df['batting_team'] + #y = ipl_df.groupby('batting_team')['delivery'].count() + y = ipl_df['delivery'] + print(x.shape,y.shape) + #plt.scatter(x,y) + plt.plot(x,y) + plt.show() + +#plot_deliveries_by_team() + # Solution + + + From f0d01612b1fe1e632b65f2d8af9f535f497a2cd4 Mon Sep 17 00:00:00 2001 From: avnishxlr8 Date: Sun, 21 Oct 2018 11:13:57 +0000 Subject: [PATCH 2/4] Done --- q02_plot_matches_by_team/build.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..53362bf 100644 --- a/q02_plot_matches_by_team/build.py +++ b/q02_plot_matches_by_team/build.py @@ -1,8 +1,20 @@ +# %load q02_plot_matches_by_team/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.switch_backend('agg') ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) - +def plot_matches_by_team(): + x_team = ipl_df['batting_team'] + #y_count = ipl_df.groupby('batting_team')['match_code'].count() + y_count = ipl_df['match_code'] + #print(y_count) + plt.scatter(x_team,y_count) + plt.plot(x_team,y_count) + plt.show() # Solution +plot_matches_by_team() + + + From 3a83c9a3517d3be3f29c41b873b18d16cccf8a19 Mon Sep 17 00:00:00 2001 From: avnishxlr8 Date: Sun, 21 Oct 2018 11:54:17 +0000 Subject: [PATCH 3/4] Done --- q03_plot_innings_runs_histogram/build.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..132ab30 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -1,8 +1,23 @@ +# %load q03_plot_innings_runs_histogram/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.switch_backend('agg') ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) - # Solution + +def plot_innings_runs_histogram(): + #x = ipl_df.where(ipl_df['inning']==1)['runs'] + x1 = ipl_df.where(ipl_df['inning']==1, other = 0)['runs'] + x2 = ipl_df.where(ipl_df['inning']==2, other = 0)['runs'] + #print(x) + plt.figure() + plt.subplot(121) + plt.hist(x1) + plt.subplot(122) + plt.hist(x2) + +plot_innings_runs_histogram() + + From a865541de6513b0e40f516d68fadbda91af75da9 Mon Sep 17 00:00:00 2001 From: avnishxlr8 Date: Sun, 21 Oct 2018 12:27:31 +0000 Subject: [PATCH 4/4] Done --- q04_plot_runs_by_balls/build.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index ce53182..e83dd53 100644 --- a/q04_plot_runs_by_balls/build.py +++ b/q04_plot_runs_by_balls/build.py @@ -1,8 +1,25 @@ +# %load q04_plot_runs_by_balls/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.switch_backend('agg') ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) - # Solution +def plot_runs_by_balls(): + ball_count = ipl_df[['match_code','batsman','delivery']].groupby(['match_code','batsman'])['delivery'].count() + runs = ipl_df[['match_code','batsman','runs']].groupby(['match_code','batsman'])['runs'].sum() + ball_count = pd.DataFrame(ball_count, columns = ['match_code','batsman','delivery']) + runs = pd.DataFrame(runs, columns = ['match_code','batsman','runs']) + #print(runs) + merged = pd.merge(ball_count,runs, left_on= 'match_code', right_on= 'match_code') + x = merged['delivery'] + y = merged['runs'] + plt.figure() + plt.subplot(111) + plt.scatter(x,y) + + +plot_runs_by_balls() + +