From f8295d2803dedc5fd01e19e8ed8e47324defb6bb Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Thu, 4 Oct 2018 15:36:12 +0000 Subject: [PATCH 1/4] 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..829b246 100644 --- a/q01_plot_deliveries_by_team/build.py +++ b/q01_plot_deliveries_by_team/build.py @@ -1,9 +1,19 @@ +# %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') + ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) # Solution +def plot_deliveries_by_team(ipl_df=ipl_df): + ipl_df['batting_team'].value_counts().plot.bar() +plot_deliveries_by_team() + + + + + From 6d30e8ed42c371ec4e40e6435784c62504d45db3 Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Thu, 4 Oct 2018 15:39:10 +0000 Subject: [PATCH 2/4] Done --- q02_plot_matches_by_team/build.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..c51f198 100644 --- a/q02_plot_matches_by_team/build.py +++ b/q02_plot_matches_by_team/build.py @@ -1,8 +1,16 @@ +# %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) +def plot_matches_by_team(): + ipl_df.groupby('batting_team').agg({'match_code': pd.Series.nunique}).plot.bar() + +plot_matches_by_team() # Solution + + + From 4e11c8eb49aa575c2d4880ca73cac171906e5d38 Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Thu, 4 Oct 2018 15:47:05 +0000 Subject: [PATCH 3/4] Done --- q03_plot_innings_runs_histogram/build.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..3c307f2 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,16 @@ # Solution +def plot_innings_runs_histogram(): + inning_wise_runs = ipl_df.groupby(['match_code', 'inning'])['runs'].sum() + first_inning_runs = inning_wise_runs[:,1] + second_inning_runs = inning_wise_runs[:,2] + fig, axs = plt.subplots(1, 2, sharey=True, tight_layout=True) + + axs[0].hist(first_inning_runs) + axs[1].hist(second_inning_runs) + + return + + + From 010a1e89306b7353181defde95b2e2910ad03f6a Mon Sep 17 00:00:00 2001 From: vidya1520 Date: Thu, 4 Oct 2018 15:49:49 +0000 Subject: [PATCH 4/4] Done --- q04_plot_runs_by_balls/build.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index ce53182..d331a81 100644 --- a/q04_plot_runs_by_balls/build.py +++ b/q04_plot_runs_by_balls/build.py @@ -1,8 +1,19 @@ +# %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(): + balls_played_by_player = ipl_df.groupby(['match_code','batsman'])['delivery'].agg('count') + runs_made_by_player = ipl_df.groupby(['match_code','batsman'])['runs'].agg('sum') + plt.scatter(balls_played_by_player, runs_made_by_player) + + return # Solution + + + +