Every sporting event today generates a lot of data about the game, which is used to analyze the performance of players, teams, and every event of the game. So the use of data science is in every sport today. Currently, IPL 2022 is one of the popular sporting events being held in India. So, if you want to learn how to analyze IPL 2022, this article is for you. In this article, I will take you through the task of IPL 2022 analysis using Python.
IPL 2022 Analysis using Python
The dataset that I am using for the task of IPL 2022 analysis is downloaded from Kaggle. You can download this dataset from here. Now let’s start this task by importing the necessary Python libraries and the dataset:
import pandas as pd import plotly.express as px import plotly.graph_objects as go data = pd.read_csv("IPL 2022.csv") print(data.head())
match_id date venue \ 0 1 March 26,2022 Wankhede Stadium, Mumbai 1 2 March 27,2022 Brabourne Stadium, Mumbai 2 3 March 27,2022 Dr DY Patil Sports Academy, Mumbai 3 4 March 28,2022 Wankhede Stadium, Mumbai 4 5 March 29,2022 Maharashtra Cricket Association Stadium,Pune team1 team2 stage toss_winner toss_decision first_ings_score \ 0 Chennai Kolkata Group Kolkata Field 131 1 Delhi Mumbai Group Delhi Field 177 2 Banglore Punjab Group Punjab Field 205 3 Gujarat Lucknow Group Gujarat Field 158 4 Hyderabad Rajasthan Group Hyderabad Field 210 first_ings_wkts second_ings_score second_ings_wkts match_winner won_by \ 0 5 133 4 Kolkata Wickets 1 5 179 6 Delhi Wickets 2 2 208 5 Punjab Wickets 3 6 161 5 Gujarat Wickets 4 6 149 7 Rajasthan Runs margin player_of_the_match top_scorer highscore best_bowling \ 0 6 Umesh Yadav MS Dhoni 50 Dwayne Bravo 1 4 Kuldeep Yadav Ishan Kishan 81 Kuldeep Yadav 2 5 Odean Smith Faf du Plessis 88 Mohammed Siraj 3 5 Mohammed Shami Deepak Hooda 55 Mohammed Shami 4 61 Sanju Samson Aiden Markram 57 Yuzvendra Chahal best_bowling_figure 0 3--20 1 3--18 2 2--59 3 3--25 4 3--22
The dataset contains all the information needed to summarize the story of IPL 2022 so far. So let’s start by looking at the number of matches won by each team in IPL 2022:
figure = px.bar(data, x=data["match_winner"], title="Number of Matches Won in IPL 2022") figure.show()

So, currently, Gujrat is leading the tournament by winning eight matches. It is an achievement as a new team for Gujrat in IPL. Now let’s see how most of the teams win. Here we will analyze whether most of the teams win by defending (batting first) or chasing (batting second):
data["won_by"] = data["won_by"].map({"Wickets": "Chasing", "Runs": "Defending"}) won_by = data["won_by"].value_counts() label = won_by.index counts = won_by.values colors = ['gold','lightgreen'] fig = go.Figure(data=[go.Pie(labels=label, values=counts)]) fig.update_layout(title_text='Number of Matches Won By Defending Or Chasing') fig.update_traces(hoverinfo='label+percent', textinfo='value', textfont_size=30, marker=dict(colors=colors, line=dict(color='black', width=3))) fig.show()

So, currently, 24 matches are won while chasing the target, and 22 matches are won while defending the target. Now let’s see what most teams prefer (batting or fielding) after winning the toss:
toss = data["toss_decision"].value_counts() label = toss.index counts = toss.values colors = ['skyblue','yellow'] fig = go.Figure(data=[go.Pie(labels=label, values=counts)]) fig.update_layout(title_text='Toss Decision') fig.update_traces(hoverinfo='label+percent', textinfo='value', textfont_size=30, marker=dict(colors=colors, line=dict(color='black', width=3))) fig.show()

Thus, most captains choose to field after winning the toss. So far, in 43 games, captains have chosen to field first, and in just three games, the captains have chosen to bat first. Now let’s see the top scorers of most IPL 2022 matches:
figure = px.bar(data, x=data["top_scorer"], title="Top Scorers in IPL 2022") figure.show()

Currently, Jos Buttler has been a top scorer in 5 matches. He is looking in great touch. Let’s analyze it deeply by including the runs scored by the top scorers:
figure = px.bar(data, x=data["top_scorer"], y = data["highscore"], color = data["highscore"], title="Top Scorers in IPL 2022") figure.show()

So till now, Jos Buttler has scored three centuries, and KL Rahul has scored two centuries. Now let’s have a look at the most player of the match awards till now in IPL 2022:
figure = px.bar(data, x = data["player_of_the_match"], title="Most Player of the Match Awards") figure.show()

So Kuldeep Yadav is leading in the list of players of the match awards with four matches. It is a great tournament for Kuldeep Yadav this year. Now let’s have a look at the bowlers with the best bowling figures in most of the matches:
figure = px.bar(data, x=data["best_bowling"], title="Best Bowlers in IPL 2022") figure.show()

You can see Yuzvendra Chahal having the best bowling figures in four matches. So this is a great tournament for Yuzvendra Chahal this year too.
Now let’s have a look at whether most of the wickets fall while setting the target or while chasing the target:
figure = go.Figure() figure.add_trace(go.Bar( x=data["venue"], y=data["first_ings_wkts"], name='First Innings Wickets', marker_color='gold' )) figure.add_trace(go.Bar( x=data["venue"], y=data["second_ings_wkts"], name='Second Innings Wickets', marker_color='lightgreen' )) figure.update_layout(barmode='group', xaxis_tickangle=-45) figure.show()

So in the Wankhede Stadium in Mumbai and MCA Stadium in Pune, most wickets fall while chasing the target. And in the other two stadiums, most wickets fall while setting the target. So this is how you can analyze and summarize the story of IPL 2022 using Python.
Summary
So this is how you can perform the task of IPL 2022 analysis using Python. IPL 2022 is going great for Gujrat as a new team this year. Jos Buttler and KL Rahul have been great with the bat, and Yuzvendra Chahal and Kuldeep Yadav have been great with the bowl. I hope you liked this article on IPL 2022 analysis using Python. Feel free to ask valuable questions in the comments section below.
Great Analysis and tutorial 🔥🔥🔥
thanks🙂