#4 E7 done#86
Open
kpflow369 wants to merge 7 commits into
Open
Conversation
Collaborator
|
To find the truly disciplined teams, we must calculate the average extras conceded per match for each team |
Author
|
@Sanjana-chennu I had done that, forgot to update |
Collaborator
|
The avg_extras variable doesn't exist yet. The code is missing the pandas logic that actually counts the number of matches played by each team and divides the total runs to get the averag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4
Visualization
Code Core Logic
team_mapping = {
"Royal Challengers Bangalore": "Royal Challengers Bengaluru",
"Rising Pune Supergiant": "Rising Pune Supergiants",
"RPS": "Rising Pune Supergiants"
}
deliveries_df["bowling_team"] = deliveries_df["bowling_team"].replace(team_mapping)
deliveries_df["batting_team"] =
deliveries_df["batting_team"].replace(team_mapping)
extras_total = deliveries_df_filtered.groupby(
['bowling_team', 'inning']
)['extra_runs'].sum().reset_index()
matches_count = deliveries_df_filtered.groupby(
['bowling_team', 'inning']
)['match_id'].nunique().reset_index()
matches_count = matches_count.rename(columns={'match_id': 'matches_played'})
avg_extras = extras_total.merge(matches_count, on=['bowling_team', 'inning'])
avg_extras['avg_extras_per_match'] = (
avg_extras['extra_runs'] / avg_extras['matches_played']
)
extras_for_viz = deliveries_df_filtered[deliveries_df_filtered['extra_runs'] > 0].copy()
viz_data_grouped = extras_for_viz.groupby(['bowling_team', 'inning', 'extras_type'])['extra_runs'].sum().reset_index()
viz_data_grouped = viz_data_grouped.rename(columns={'extra_runs': 'total_runs'})
viz_data_melted_filtered = viz_data_grouped[viz_data_grouped['extras_type'].isin(['wides', 'noballs', 'legbyes', 'byes'])]
g = sns.catplot(data=viz_data_melted_filtered, x='bowling_team',y='total_runs',hue='extras_type',col='inning',kind='bar',palette='viridis',errorbar=None,height=6, aspect=1.5)
g.set_axis_labels('Bowling Team', 'Total Runs Conceded')
g.set_titles('Inning {col_name}')
g.set_xticklabels(rotation=45, ha='right')
plt.suptitle('Breakdown of Extra Types Conceded by Bowling Team (1st vs 2nd Innings)', y=1.02, fontsize=16)
plt.tight_layout(rect=[0, 0, 1, 0.98])
plt.show()
Summary
Wides dominate: Most of the extra runs given by teams come from wides in both innings.
More extras in 2nd innings: Teams usually give more extras in the second innings, probably due to pressure, fatigue, or aggressive bowling.
Byes & no-balls are less: Compared to wides and leg-byes, byes and no-balls contribute much less to extras.
Teams with fewer extras: Gujarat Lions give the least extras on average, followed by teams like Pune Warriors.
Teams needing improvement: Teams like Mumbai Indians, RCB, KKR, and SRH give a lot of wides, so controlling wides is important for them.