From 58613c86e1c06dd960d16bc7d07a4ee3df67762e Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Wed, 28 Nov 2018 02:35:51 +0000 Subject: [PATCH 1/4] Done --- q01_plot_deliveries_by_team/build.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..fbc879c 100644 --- a/q01_plot_deliveries_by_team/build.py +++ b/q01_plot_deliveries_by_team/build.py @@ -1,9 +1,23 @@ +#%load q01_plot_deliveries_by_team/build.py + import pandas as pd import numpy as np -import matplotlib.pyplot as plt -plt.switch_backend('agg') +from matplotlib import pyplot as plt + +ipl_df=pd.read_csv('./data/ipl_dataset.csv') + +# gr=ipl_df.groupby('batting_team').delivery.agg('count') + +# plt.bar(gr.index,gr,title='Bar graph of \n Batting team vs count of deliveries ') +# plt.show() +def plot_deliveries_by_team(): + ipl_df.groupby('batting_team').delivery.agg('count').plot(kind='bar',title='Batting team vs count of deliveries ') + plt.xlabel=('batsman') + plt.ylabel=('runs') + plt.show() + +plot_deliveries_by_team() + -ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) -# Solution From 5b4a4e3fa78441e8eab174f5e972d0f300e43e1d Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Wed, 28 Nov 2018 02:49:09 +0000 Subject: [PATCH 2/4] Done --- q02_plot_matches_by_team/build.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..0bd6c7e 100644 --- a/q02_plot_matches_by_team/build.py +++ b/q02_plot_matches_by_team/build.py @@ -1,8 +1,23 @@ +#%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) + +from matplotlib import pyplot as plt + +ifl_df=pd.read_csv('./data/ipl_dataset.csv') + +def plot_matches_by_team(): + gr=ifl_df.groupby('batting_team')['match_code'].nunique() + gr.plot(kind='bar',title=' total number of matches played by each team') + + plt.xlabel('batsman') + plt.ylabel('matches played') + + plt.show() + +plot_matches_by_team() + + -# Solution From 02da07feda25d57da0345d90fe9629886e1fe855 Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Thu, 29 Nov 2018 06:25:03 +0000 Subject: [PATCH 3/4] Done --- q04_plot_runs_by_balls/build.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index ce53182..f539140 100644 --- a/q04_plot_runs_by_balls/build.py +++ b/q04_plot_runs_by_balls/build.py @@ -1,8 +1,29 @@ +#%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) +from matplotlib import pyplot as plt + +ifl_df=pd.read_csv('./data/ipl_dataset.csv') +# ifl_df.columns +# runs,delivery,batsman + +def plot_runs_by_balls(): + + gr=ifl_df.groupby('batsman') + balls=pd.DataFrame(gr['delivery'].count()) + runs=pd.DataFrame(gr['runs'].sum()) + + A=balls.merge(runs, left_index=True,right_index=True, how='inner') + + plt.scatter(A.runs,A.delivery) + plt.xlabel=('runs') + plt.ylabel=('deliveries') + + plt.show() + +# runs + +# plt.scatter(ifl_df[) -# Solution From a3beef3c25eae38dcdf54020522fabba455717cc Mon Sep 17 00:00:00 2001 From: Ajpalav Date: Sat, 1 Dec 2018 08:44:19 +0000 Subject: [PATCH 4/4] Done --- q03_plot_innings_runs_histogram/build.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..013eae8 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -1,8 +1,22 @@ -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) +import pandas as pd +from matplotlib import pyplot as plt + +ifl_df=pd.read_csv('./data/ipl_dataset.csv') + +def plot_innings_runs_histogram(): + + gr=ifl_df.groupby(['match_code','inning'])['runs'].sum() +#gr[1::2] + + fig = plt.figure() + ax = fig.add_subplot(121) + gr[1::2].plot(kind='hist',title=' total number of runs inning 1') + ax = fig.add_subplot(122) + gr[2::2].plot(kind='hist',title=' total number of runs inning 2') + + plt.show() + +plot_innings_runs_histogram() -# Solution