diff --git a/q01_plot_deliveries_by_team/build.py b/q01_plot_deliveries_by_team/build.py index d1dab11..c54e6d5 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,16 @@ # Solution + +def plot_deliveries_by_team(): + all_teams = ipl_df['batting_team'] + x_series = pd.Series(all_teams.value_counts().index) + y_series = pd.Series(all_teams.value_counts().values) + + plt.bar(x_series,y_series) + plt.xticks(rotation = 45) + plt.title('graph') + plt.xlabel('batting_team') + plt.ylabel('delivery') + plt.show() + diff --git a/q02_plot_matches_by_team/build.py b/q02_plot_matches_by_team/build.py index ce53182..a85b604 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,21 @@ # Solution +def plot_matches_by_team(): + team_details = ipl_df.groupby(['batting_team','match_code']).count() + teams_per_match = team_details.index.values + teams_details = [] + + for x in range(0,len(teams_per_match)): + teams_details.append(teams_per_match[x][0]) + + values, counts = np.unique(teams_details, return_counts=True) + x1_series = list(values) + y1_series = list(counts) + plt.bar(x1_series,y1_series) + plt.xticks(x1_series , rotation = 90) + plt.xlabel('batting_team') + plt.ylabel('delivery') + plt.show() + + diff --git a/q03_plot_innings_runs_histogram/build.py b/q03_plot_innings_runs_histogram/build.py index ce53182..c421349 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,18 @@ # Solution + +def plot_innings_runs_histogram(): + inningwise_data = ipl_df.groupby(['inning','match_code']).sum() + inningwise_data.sort_index(inplace=True) + + match_codes = list(inningwise_data.loc[(1.0),'runs'].index.values) + first_innings_scores = list(inningwise_data.loc[(1.0),'runs']) + second_innings_scores = list(inningwise_data.loc[(2.0),'runs']) + + fig,axes = plt.subplots(1,2) + + axes[0].hist(first_innings_scores , bins = 5) + + axes[1].hist(second_innings_scores , bins = 5) + diff --git a/q04_plot_runs_by_balls/build.py b/q04_plot_runs_by_balls/build.py index ce53182..a68238b 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,11 @@ # Solution +def plot_runs_by_balls(): + return None +def plot_runs_by_balls(): + return None + + + +