diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index dd835d0..8b8f599 100644 --- a/q01_plot_deliveries_by_team/build.py +++ b/q01_plot_deliveries_by_team/build.py @@ -6,3 +6,8 @@ # Solution +def plot_deliveries_by_team(): + team_delivery = ipl_df.pivot_table('delivery', aggfunc = np.count_nonzero, index ='batting_team') + + team_delivery.plot(kind = 'bar') + plt.show() diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index dd835d0..ef92673 100644 --- a/q02_plot_matches_by_team/build.py +++ b/q02_plot_matches_by_team/build.py @@ -6,3 +6,10 @@ # Solution +def plot_matches_by_team(): + ipl_df['count'] = 1 + data = ipl_df[['batting_team','match_code','count']] + matches = data.groupby(['batting_team','match_code']).agg(np.unique) + teams = matches['count'].groupby(['batting_team']).sum() + bar_plot = teams.plot(kind = 'bar') + plt.show() diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index dd835d0..d225c30 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -6,3 +6,13 @@ # Solution +def plot_innings_runs_histogram(): + a = ipl_df.groupby(by=['match_code','inning'],as_index=0)['runs'].count() + b= a[a['inning']==1]#['runs'] + c= a[a['inning']==2]#['runs'] + #x =pd.DataFrame(columns=[b,c]) + plt.subplot(1,2,1) + b['runs'].hist()#.groupby(by='runs').count()#['inning'].hist() + plt.subplot(1,2,2) + c['runs'].hist() + plt.show() diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index dd835d0..3a1a345 100644 --- a/q04_plot_runs_by_balls/build.py +++ b/q04_plot_runs_by_balls/build.py @@ -6,3 +6,10 @@ # Solution +def plot_runs_by_balls(): + data = ipl_df[['batsman','delivery','runs']] + batsman = data.groupby(['batsman']) + balls = batsman['delivery'].count() + runs = batsman['runs'].sum() + plt.scatter(balls,runs) + plt.show()