diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..fe0b801 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 @@ -5,5 +6,17 @@ ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) - # Solution +def plot_deliveries_by_team(): + + newData = ipl_df.groupby(['batting_team']).agg('count') + x = newData.index.values + y = newData['delivery'].values + plt.barh(x, y) + plt.show() + +plot_deliveries_by_team() + + + + diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..be41e1b 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,15 @@ # Solution +def plot_matches_by_team(): + newData = ipl_df.groupby(['batting_team']).agg('nunique') + x = newData.index.values + y = newData['match_code'].values + plt.barh(x, y) + plt.show() + +plot_matches_by_team() + + + + diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..b23de8f 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,14 @@ # Solution +def plot_innings_runs_histogram(): + + newData = ipl_df.groupby(['match_code', 'inning']).agg('sum') + x = newData['runs'].values + num_bins = 50 + + plt.hist(x, num_bins, facecolor='blue', alpha=0.5) + +plot_innings_runs_histogram() + +