From eac3b4ce49c783f766cd502a08ab2538199a485e Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Fri, 4 Jan 2019 10:57:29 +0000 Subject: [PATCH 1/4] Done --- q01_plot_deliveries_by_team/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..22ed586 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 @@ -6,4 +7,9 @@ ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) -# Solution +def plot_deliveries_by_team(): + ipl1=ipl_df.groupby('team1').match_code.agg(['count']) + ipl1.plot(kind='bar') +plot_deliveries_by_team() + + From 89a2dc753b97b93dd4e31b0fa52b5aadf5048186 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Fri, 4 Jan 2019 11:33:37 +0000 Subject: [PATCH 2/4] Done --- q02_plot_matches_by_team/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..aaeb571 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 @@ -5,4 +6,9 @@ ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) -# Solution +def plot_matches_by_team(): + ipl1=ipl_df.groupby('batting_team').match_code.agg(['nunique']) + ipl1.plot.bar() + + + From 920aab37e613638db9a41156d1d96ac109f9ce77 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Wed, 9 Jan 2019 09:29:07 +0000 Subject: [PATCH 3/4] Done --- q03_plot_innings_runs_histogram/build.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..dc0ef26 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -1,8 +1,30 @@ +# %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) +def plot_innings_runs_histogram(): + ipl_df1=ipl_df.groupby(['inning','match_code'], as_index=False)['runs'].sum() + fig,axs=plt.subplots(1,2) + axs[0].hist(ipl_df1[ipl_df1.inning==1].runs) + axs[0].set_title('First Inning runs distribution') + axs[1].hist(ipl_df1[ipl_df1.inning==2].runs) + axs[1].set_title('Second Inning runs distribution') + plt.show() + fig +fig +ipl_df1=ipl_df.groupby(['inning','match_code'], as_index=False)['runs'].sum() +ipl_df1 +ipl_df1[ipl_df1.inning==1].runs +ipl_df1[ipl_df1.inning==2].runs +fig,axs=plt.subplots(1,2) +axs[0].hist(ipl_df1[ipl_df1.inning==1].runs) +axs[0].set_title('First Inning runs distribution') +axs[1].hist(ipl_df1[ipl_df1.inning==2].runs) +axs[1].set_title('Second Inning runs distribution') +plt.show() +fig + -# Solution From 764f12e8def39f2a4d107e18ec4c67561bba8ef0 Mon Sep 17 00:00:00 2001 From: Sandesh373 Date: Wed, 9 Jan 2019 10:02:40 +0000 Subject: [PATCH 4/4] Done --- q04_plot_runs_by_balls/build.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index ce53182..bb1fea8 100644 --- a/q04_plot_runs_by_balls/build.py +++ b/q04_plot_runs_by_balls/build.py @@ -1,8 +1,24 @@ +# %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) +def plot_runs_by_balls(): + ipl_runs=ipl_df.groupby(['batsman','match_code'],as_index=False).runs.sum() + ipl_balls=ipl_df.groupby(['batsman','match_code'],as_index=False).runs.count() + ipl_balls.rename(columns={'runs':'balls'},inplace=True) + ipl3=pd.concat([ipl_runs, ipl_balls], axis=1, join='inner') + fig,axs=plt.subplots(1,1) + axs.scatter(ipl3['balls'],ipl3['runs']) + plt.show() + fig +plot_runs_by_balls() +ipl_balls=ipl_df.groupby(['batsman','match_code'],as_index=False).runs.count() +ipl_balls.rename(columns={'runs':'balls'},inplace=True) +ipl3=pd.concat([ipl_runs, ipl_balls], axis=1, join='inner') +fig,axs=plt.subplots(1,1) +axs.scatter(ipl3['balls'],ipl3['runs']) +fig -# Solution