From e9e6b21f77b7c1b6cbfdd564e28b3b88d27b77bb Mon Sep 17 00:00:00 2001 From: sagark93 Date: Mon, 21 Jan 2019 11:08:33 +0000 Subject: [PATCH 1/4] Done --- q01_plot_deliveries_by_team/build.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..f948f1c 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,17 @@ ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) +ipl_df.columns # Solution +def plot_deliveries_by_team(): + delivery_count = ipl_df.groupby(['batting_team'])['delivery'].agg('count') + plt.bar(ipl_df['batting_team'].value_counts(), delivery_count,align='center', alpha=0.5) +#ipl_df['runs'].groupby('match_code').agg('count') +#ipl_df.groupby(['batting_team','delivery'].count() +plot_deliveries_by_team() +#ipl_df.batting_team.unique != 'Mumbai Indians' +#ipl_df['batting_team'].nunique +#ipl_df.groupby(['batting_team'])['delivery'].agg('count') + +ipl_df['batting_team'].value_counts() + From c85103051c40e33858fd6a477952fc8ab3c483a1 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Mon, 21 Jan 2019 11:32:09 +0000 Subject: [PATCH 2/4] Done --- q02_plot_matches_by_team/build.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..42e55a2 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,21 @@ # Solution + +def plot_matches_by_team(): + batting_team = ipl_df['batting_team'] + matches_count = batting_team.value_counts() + x_series = np.arange(len(matches_count.index)) + plt.bar(x_series, matches_count) + plt.xticks(x_series, matches_count.index.values, rotation=90) + plt.show() + + +plot_matches_by_team() + + + + + + + From 943572738c384b2d4cc0ddc566bc7ad1ca612784 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Mon, 21 Jan 2019 12:44:40 +0000 Subject: [PATCH 3/4] Done --- q03_plot_innings_runs_histogram/build.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..f4be3a4 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -1,8 +1,26 @@ +# %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) - # Solution + +def plot_innings_runs_histogram(): + inning_1 = ipl_df[ipl_df['inning'] == 1] + inning_2 = ipl_df[ipl_df['inning'] == 2] + sum_innings_1 = inning_1['runs'].sum() + sum_innings_2 = inning_2['runs'].sum() + plt.hist(sum_innings_1, sum_innings_2) +plot_innings_runs_histogram() +inning_1 = ipl_df[ipl_df['inning'] == 1] +inning_2 = ipl_df[ipl_df['inning'] == 2] +inning_1 = batting_team.value_counts('1') +inning_2 = batting_team.value_counts('2') +#x_series = np.arange(len(deliveries_by_team.index)) +#plt.bar(x_series, deliveries_by_team) +#plt.xticks(x_series, deliveries_by_team.index.values, rotation=90) +#plt.show() +inning_2['runs'].sum() + From ca96157a2cb18a1e47125afab934af91bfac4b98 Mon Sep 17 00:00:00 2001 From: sagark93 Date: Mon, 21 Jan 2019 13:07:54 +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..0547cbf 100644 --- a/q04_plot_runs_by_balls/build.py +++ b/q04_plot_runs_by_balls/build.py @@ -1,3 +1,4 @@ +# %load q04_plot_runs_by_balls/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt @@ -6,3 +7,13 @@ # Solution +def plot_runs_by_balls(): + sum_of_runs = ipl_df.groupby(['match_code','batsman'])['runs'].agg('sum') + count_of_balls = ipl_df.groupby(['match_code','batsman'])['delivery'].agg('count') + plt.scatter(count_of_balls,sum_of_runs) + plt.show() +sum_of_runs = ipl_df.groupby(['match_code','batsman'])['runs'].agg('sum') +count_of_balls = ipl_df.groupby(['match_code','batsman'])['delivery'].agg('count') +plot_runs_by_balls() + +