Skip to content

#4 E7 done#86

Open
kpflow369 wants to merge 7 commits into
iiitl:mainfrom
kpflow369:bug4
Open

#4 E7 done#86
kpflow369 wants to merge 7 commits into
iiitl:mainfrom
kpflow369:bug4

Conversation

@kpflow369

@kpflow369 kpflow369 commented Apr 12, 2026

Copy link
Copy Markdown

Closes #4

Visualization

image image

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.

@Sanjana-chennu

Copy link
Copy Markdown
Collaborator

To find the truly disciplined teams, we must calculate the average extras conceded per match for each team

@kpflow369

Copy link
Copy Markdown
Author

@Sanjana-chennu I had done that, forgot to update

@Sanjana-chennu

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E7: Team Extras Conceded

2 participants