diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..060f485 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,10 @@ # Solution +def plot_deliveries_by_team(): + delieveries=ipl_df[['batting_team','delivery']].groupby('batting_team').count().sort_values(by='delivery',ascending=False) + delieveries.plot(kind='bar') + plt.show() + #r + + diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..cba1be2 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,10 @@ # Solution +def plot_matches_by_team(): + match_count_per_teams=ipl_df[['batting_team','match_code']].groupby('batting_team').aggregate('nunique') + Series_of_matches=np.arange(len(match_count_per_teams.index)) + plt.bar('bbatting_team',match_count_per_teams['match_code']) +plot_matches_by_team() + + diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..e1b2582 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,19 @@ # Solution +def plot_innings_runs_histogram(): + group_innings = ipl_df.groupby(['match_code', 'inning']).sum().reset_index() + group_innings.head() + inning1_df = group_innings[group_innings['inning'] == 1] + inning2_df = group_innings[group_innings['inning'] == 2] + + + fig, axes = plt.subplots(1, 2) + + axes[0].hist(inning1_df['runs']) + axes[1].hist(inning2_df['runs']) + plt.show(); + +plot_innings_runs_histogram() + + diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index ce53182..b9370ab 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,10 @@ # Solution +def plot_runs_by_balls(): + runs_per_delivery=ipl_df[['runs','delivery']].groupby('delivery').sum() + plt.scatter(runs_per_delivery.index,runs_per_delivery['runs']) + plt.show() + + +