From f3f98daa5cc9b061a19adb39262ac484df4ff37f Mon Sep 17 00:00:00 2001 From: iampa1 Date: Wed, 17 Oct 2018 04:51:29 +0000 Subject: [PATCH 1/3] Done --- q01_plot_deliveries_by_team/build.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..572ceef 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 @@ -7,3 +8,24 @@ # Solution + +def plot_deliveries_by_team(): + x=ipl_df.groupby('batting_team').delivery.count() + plt.bar(x.index,x.values) + plt.show() + +plt.bar([1,2,3],[1,4,9]) +plt.show() +x=ipl_df.groupby('batting_team').delivery.count() +type(x) +plt.bar(x,height=2) +plt.show() +x +x[0] +x[1] +x.index +x.values +u=x.index +np.array(u) + + From 076c90502c4a8c0eee826f4184c3d57fd0fb2ce0 Mon Sep 17 00:00:00 2001 From: iampa1 Date: Wed, 17 Oct 2018 13:41:47 +0000 Subject: [PATCH 2/3] Done --- q02_plot_matches_by_team/build.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..b3df5b3 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,14 @@ # Solution +def plot_matches_by_teams(): + x=ipl_df.groupby('batting_team').match_code.nunique() + plt.bar(x.index, x.values) + plt.show() +x=ipl_df.groupby('batting_team').match_code.nunique() +x.index +x.values +plt.bar(x.index,x.values) +plt.show() + + From cc38ec60bc72fa3368041808416dd29fe90d760f Mon Sep 17 00:00:00 2001 From: iampa1 Date: Mon, 14 Jan 2019 12:53:27 +0000 Subject: [PATCH 3/3] Done --- q03_plot_innings_runs_histogram/build.py | 34 ++++++++++++++++++++++++ q04_plot_runs_by_balls/build.py | 15 +++++++++++ 2 files changed, 49 insertions(+) diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..f58be07 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -1,8 +1,42 @@ +# %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_innigs_runs_histogram(): + x=ipl_df[ipl_df['toss_decision']=='bat']['total'] + y=ipl_df[ipl_df['toss_decision']=='field']['total'] + fig, ax = plt.subplots(1,2) + ax[0].hist(x, bins=10, alpha = 0.5, color = 'r') + ax[1].hist(y, bins=10, alpha = 0.5, color = 'g') + plt.show() + +x=ipl_df[ipl_df['toss_decision']=='bat']['total'] +y=ipl_df[ipl_df['toss_decision']=='field']['total'] +plt.subplots(2,1) +plt.hist(y,bins=10) + + +# An 'interface' to matplotlib.axes.Axes.hist() method +n, bins, patches = plt.hist(x=x, bins='auto', color='#0504aa', + alpha=0.7, rwidth=0.85) +plt.grid(axis='y', alpha=0.75) +plt.xlabel('Value') +plt.ylabel('Frequency') +plt.title('My Very Own Histogram') +plt.text(23, 45, r'$\mu=15, b=3$') +maxfreq = n.max() +# Set a clean upper y-axis limit. +plt.ylim(ymax=np.ceil(maxfreq / 10) * 10 if maxfreq % 10 else maxfreq + 10) +fig, ax = plt.subplots(1,2) +ax[0].hist(x, bins=10, alpha = 0.5, color = 'r') +ax[1].hist(y, bins=10, alpha = 0.5, color = 'g') +plt.show() +plot_innigs_runs_histogram() + + diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index ce53182..40d841c 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,17 @@ # Solution +def plot_runs_by_balls(): + plt.scatter(ipl_df['runs'],ipl_df.index) + plt.show() + + +plt.scatter(ipl_df['runs'],ipl_df.index) +plt.show() +fig, ax = plt.subplots(1,2) +ax[0].hist(x, bins=10, alpha = 0.5, color = 'r') +ax[1].hist(y, bins=10, alpha = 0.5, color = 'g') +plt.show() +plot_runs_by_balls() + +