diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..3a86448 100644 --- a/q01_plot_deliveries_by_team/build.py +++ b/q01_plot_deliveries_by_team/build.py @@ -5,5 +5,15 @@ ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) +def plot_deliveries_by_team(): + count_deliveries = ipl_df.groupby(['batting_team']).agg('count')['delivery'] + count_deliveries.plot(kind = 'bar') + + plt.show(); + + + +plot_deliveries_by_team() + + -# Solution diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..f8cbe24 100644 --- a/q02_plot_matches_by_team/build.py +++ b/q02_plot_matches_by_team/build.py @@ -4,5 +4,13 @@ plt.switch_backend('agg') ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) +def plot_matches_by_team(): + count_matches = ipl_df.groupby(['batting_team']).agg('nunique')['match_code'] + count_matches.plot(kind = 'bar') + plt.show(); + +plot_matches_by_team() + + + -# Solution diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..baa1b4c 100644 --- a/q03_plot_innings_runs_histogram/build.py +++ b/q03_plot_innings_runs_histogram/build.py @@ -4,5 +4,11 @@ plt.switch_backend('agg') ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) +def plot_innings_runs_histogram(): + f1_match = ipl_df.groupby(['match_code','inning']).agg('sum')['total'] + f1_match.plot(kind= 'hist', subplots= True) + plt.show(); + +plot_innings_runs_histogram() + -# Solution diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index ce53182..3289bb2 100644 --- a/q04_plot_runs_by_balls/build.py +++ b/q04_plot_runs_by_balls/build.py @@ -4,5 +4,16 @@ plt.switch_backend('agg') ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None) +def plot_runs_by_balls(): + runs_scored = pd.DataFrame(ipl_df.groupby(['match_code', 'batsman']).agg('sum')['runs']) + balls_played = pd.DataFrame(ipl_df.groupby(['match_code', 'batsman']).agg('count')['delivery']) + playedscored = runs_scored.join(balls_played) + plt.scatter(playedscored['runs'], playedscored['delivery']) + plt.show(); + + + +plot_runs_by_balls() + + -# Solution