From c36e1450e45306aa63c1643cafad0b687346e928 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Fri, 1 Feb 2019 05:32:51 +0000 Subject: [PATCH 1/3] Done --- q01_plot_deliveries_by_team/build.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..1b22500 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,27 @@ # Solution +def plot_deliveries_by_team(): + a=ipl_df.groupby('batting_team').agg({'delivery':'count'}).reset_index() + a.plot(kind='bar') + plt.xticks(index,list(a['batting_team'])) + plt.xlabel('Batting team') + plt.ylabel('Deliveries') + plt.show() + + a=ipl_df.groupby('batting_team').agg({'delivery':'count'}).reset_index() + a['delivery'] + type(a) + a.iloc[:,0] + + a=a.reset_index() + a.iloc[:,0] + x=a[['batting_team','delivery']].plot(kind='bar') + plt.show() + x + x=a[['batting_team','delivery']].plot(kind='bar') + x + plt.show() + x + + From a5111a93eda173bd08e627d843fe17e4c8aea3bf Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Fri, 1 Feb 2019 06:47:40 +0000 Subject: [PATCH 2/3] Done --- q02_plot_matches_by_team/build.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..9428bf1 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,15 @@ # Solution +def plot_matches_by_teams(): + a=ipl_df.groupby('batting_team').match_code.nunique() + plt.bar(a.index, a.values) + plt.show() + a=ipl_df.groupby('batting_team').match_code.nunique() + a.index + a.values + plt.bar(a.index,a.values) + plt.show() + + + From cce1ac6b636b399ea997d94675ed6244656b3a6a Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Fri, 1 Feb 2019 06:52:22 +0000 Subject: [PATCH 3/3] Done --- q03_plot_innings_runs_histogram/build.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..f88f0aa 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -1,3 +1,4 @@ +# %load q03_plot_innings_runs_histogram/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt @@ -6,3 +7,22 @@ # Solution +def plot_innings_runs_histogram(): + i=ipl_df.groupby(['match_code','inning']).agg({'runs':'sum'}) + t1=i.groupby('inning').get_group(1)['runs'] + t2=i.groupby('inning').get_group(2)['runs'] + fig=plt.figure() + plt.subplot(1,2,1) + plt.hist(t1) + plt.subplot(1,2,2) + plt.hist(t2) + plt.show() + i=ipl_df.groupby(['match_code','inning']).agg({'runs':'sum'}) + type(i) + i.iloc[0,0] + t1=i.groupby('inning').get_group(1)['runs'] + t1 + t2=i.groupby('inning').get_group(2)['runs'] + 2 + +