From 18552ed55d4ae5650c4abe627cee9492b00d3b2c Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Fri, 28 Sep 2018 15:54:14 +0000 Subject: [PATCH 1/5] Done --- q01_plot_deliveries_by_team/build.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..0eab31a 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 @@ -7,3 +8,12 @@ # Solution +def plot_deliveries_by_team(): + count=ipl_df.groupby(ipl_df['batting_team']).agg('count') + plt.bar(count.index,count['delivery']) + plt.title('Deliveries/teams') + plt.xlabel('batting_teams') + plt.ylabel('Deliveries') + plt.show() +plot_deliveries_by_team() + From e497e1c538fca33cc22f1a9aa768f18cc8e274d9 Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Fri, 28 Sep 2018 17:53:24 +0000 Subject: [PATCH 2/5] Done --- q02_plot_matches_by_team/build.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..7fc1bee 100644 --- a/q02_plot_matches_by_team/build.py +++ b/q02_plot_matches_by_team/build.py @@ -1,3 +1,4 @@ +# %load q02_plot_matches_by_team/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt @@ -6,3 +7,14 @@ # Solution +def plot_matches_by_team(): + count=ipl_df.groupby(ipl_df['batting_team']).agg('nunique') + plt.bar(count.index,count['batting_team']) + plt.title('count of matches/teams') + plt.xlabel('batting_teams') + plt.ylabel('count of matches') + plt.xticks(count.index,rotation=90) + plt.show() +plot_matches_by_team() + + From bbeb0f45f0d8ada4a86f921ca1e5b494326d7b83 Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Fri, 28 Sep 2018 17:58:19 +0000 Subject: [PATCH 3/5] Done --- q02_plot_matches_by_team/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index 7fc1bee..70803fb 100644 --- a/q02_plot_matches_by_team/build.py +++ b/q02_plot_matches_by_team/build.py @@ -9,7 +9,7 @@ # Solution def plot_matches_by_team(): count=ipl_df.groupby(ipl_df['batting_team']).agg('nunique') - plt.bar(count.index,count['batting_team']) + plt.bar(count.index,count['match_code']) plt.title('count of matches/teams') plt.xlabel('batting_teams') plt.ylabel('count of matches') From 5b169e2c82244d5aa3704b522239fe99643e5437 Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Thu, 4 Oct 2018 18:37:21 +0000 Subject: [PATCH 4/5] Done --- q03_plot_innings_runs_histogram/build.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..7dbcf72 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -1,8 +1,21 @@ +# %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') +#plt.switch_backend('agg') ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) # Solution +def plot_innings_runs_histogram(): + i1=ipl_df[ipl_df['inning']==1] + x=i1.groupby(ipl_df['match_code']).agg('sum') + + i2=ipl_df[ipl_df['inning']==2] + y=i2.groupby(ipl_df['match_code']).agg('sum') + fig, axs = plt.subplots(1, 2, sharey=True) + axs[0].hist(x['runs']) + axs[1].hist(y['runs']) + fig.show() +plot_innings_runs_histogram() + From d549831baa156a2dd6a4f6758b6400f00e45c598 Mon Sep 17 00:00:00 2001 From: RohanUnni Date: Thu, 4 Oct 2018 19:25:57 +0000 Subject: [PATCH 5/5] Done --- q04_plot_runs_by_balls/build.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index ce53182..be679e2 100644 --- a/q04_plot_runs_by_balls/build.py +++ b/q04_plot_runs_by_balls/build.py @@ -1,3 +1,4 @@ +# %load q04_plot_runs_by_balls/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt @@ -6,3 +7,11 @@ # Solution +def plot_runs_by_balls(): + bat=ipl_df.groupby(['batsman','match_code']).agg({'runs':sum,'delivery':'count'}) + plt.scatter(bat.delivery,bat.runs) + plt.xlabel('balls faced') + plt.ylabel('runs scored') + plt.show() +plot_runs_by_balls() +