diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index dd835d0..bc624e7 100644 --- a/q01_plot_deliveries_by_team/build.py +++ b/q01_plot_deliveries_by_team/build.py @@ -1,8 +1,12 @@ +# %load q01_plot_deliveries_by_team/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) - - -# Solution +data = ipl_df.pivot_table(values='delivery',index=['batting_team'],aggfunc='count') +data.plot(kind='bar') +plt.title('Number of Deliveries Faced by IPL Teams') +plt.xlabel('IPL Teams') +plt.ylabel('Number of Deliveries') +plt.show() diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index dd835d0..d3a357e 100644 --- a/q02_plot_matches_by_team/build.py +++ b/q02_plot_matches_by_team/build.py @@ -1,8 +1,13 @@ +# %load q02_plot_matches_by_team/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) - - -# Solution +def plot_matches_by_team(): + a=ipl_df.groupby(by='batting_team').nunique() + plot=a['match_code'].plot(kind='bar') + plot.set_ylabel("Match_Count") + plot.set_xlabel("Teams") + plt.show() +plot_deliveries_by_team() diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index dd835d0..f1dff58 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -1,8 +1,16 @@ +# %load q03_plot_innings_runs_histogram/build.py import pandas as pd import numpy as np import matplotlib.pyplot as plt ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) - -# Solution +def plot_innings_runs_histogram(): + pivot = ipl_df.pivot_table(values=['runs'], index=['match_code'], columns='inning', aggfunc='count') + inning_1 = pivot['runs'][1] + inning_2 = pivot['runs'][2] + plt.subplot(1,2,1) + inning_1.hist() + plt.subplot(1,2,2) + inning_2.hist() + plt.show() diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index dd835d0..466910f 100644 --- a/q04_plot_runs_by_balls/build.py +++ b/q04_plot_runs_by_balls/build.py @@ -4,5 +4,9 @@ ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) +def plot_runs_by_balls(): + table = ipl_df.pivot_table(index ='delivery', values=['runs'], aggfunc = np.sum) + plt.scatter(table.index,table['runs']) + plt.show() # Solution